HN user

aban

544 karma

Amin Bandali -- https://aminb.org

Computer Scientist. Into Haskell and Elisp.

topcolor: ffbb33 (previously c6c6c6)

[ my public key: https://keybase.io/amin; my proof: https://keybase.io/amin/sigs/UYO-kN31F2vPwJvP8DYLwTeGBihIAV6FjcWIU5QLryY ]

Posts2
Comments72
View on HN

Thank you so much for sharing this. This, and When Worlds Collide, are some of the most touching pieces I've ever read.

Rest in peace John.

Typing Nix 9 years ago

Neat. Somewhat related is hnix [0], a community effort in re-implementing the Nix expression language in Haskell.

While so far the focus has mostly been on implementing the expression language as is, hnix being written in Haskell could be attractive for enriching the language with fancier features:

"Because now that it's in Haskell, now that a lot of other hackers could get involved, we could do things like add optional typing to the Nix language." — J. Wiegley

For more on hnix check out Haskell Cast's Episode 13 [1] with John Wiegley.

[0] https://github.com/jwiegley/hnix

[1] http://www.haskellcast.com/episode/013-john-wiegley-on-categ...

Agreed. I feel like the state of documentation of Haskell libraries in general could be much better.

There was actually a thread on /r/haskell a few months ago [0] in response to an HN comment. In that thread, a few libraries were mentioned as examples of having amazing docs.

For instance, Gabriel Gonzalez writes a Tutorial module for his libraries, which introduces the basics of the library and shows you the big picture. The tutorial walks you through different pieces of the library, how to use them, and how they come together.

It's hands down one of the most effective ways of documenting I've ever seen and I'd love to see other communities' take on it.

To point out a specific example, you should check out Turtle's tutorial [1].

[0] https://www.reddit.com/r/haskell/comments/5khts3/on_haskell_...

[1] https://hackage.haskell.org/package/turtle-1.3.3/docs/Turtle...

That's a good explanation of Monoids. You can also watch (at least the first half) of this video for more on Monoids:

https://www.youtube.com/watch?v=WsA7GtUQeB8

There are already a good number of people trying to explain Monads in this thread, so I won't attempt it. But I'll say this (in the context of Haskell):

In Haskell, like how Monoid is a typeclass, Monad is just another typeclass. So me mentioning "typeclass" twice in a sentence suggests that you probably have to first understand typeclasses and data types.

Also, I wouldn't recommend tackling Monad right after grasping Monoid. I'd recommend you read about and understand Functor and Applicative functors first, and that will ease you into understanding Monads and actually why you would want to have them.

So, you may want to read these pages from Wikibooks in this order:

https://en.wikibooks.org/wiki/Haskell/Classes_and_types

https://en.wikibooks.org/wiki/Haskell/The_Functor_class

https://en.wikibooks.org/wiki/Haskell/Applicative_functors

https://en.wikibooks.org/wiki/Haskell/Applicative_prologue

The last link is the first section of a chapter on Monads; so use the links on the sidebar to read the subsequent sections of the chapter.

Typeclassopedia is another great resource for the typeclasses I mentioned: https://wiki.haskell.org/Typeclassopedia

What the parent said.

To be even more specific, network management is really distro- and DE-agnostic. For instance, Arch wiki describes a multitude of ways for wired [0] and wireless [1] network configuration, that would technically work in other distros as well.

Most distros and DEs ship with Gnome's NetworkManager [2] but with different front-ends: distros with GTK-based DEs like Gnome or Unity usually ship network-manager-applet, and distros with Qt-based DEs like KDE usually ship plasma-nm or networkmanager-qt.

Power management [3] is a bit different. There are distro-specific recommendations and also 3rd party apps, but DEs usually have their own power manager.

Now, when you choose to use a DE, the choice of which network or power management solution you use is already made for you, but when you don't use a DE then you will be choosing them yourself.

[0] https://wiki.archlinux.org/index.php/Network_configuration [1]: https://wiki.archlinux.org/index.php/Wireless_network_config...

[2] https://wiki.archlinux.org/index.php/NetworkManager [3]: https://wiki.archlinux.org/index.php/Power_management

Yup, been there too, but I simply can't go back to a non-tiling WM after being spoiled with tiling ones.

If you want to give it a shot, there's a guide on using Awesome with Gnome [0], and the last time I tried it worked just fine. Though, awesome replaces both mutter (Gnome's WM) and the Gnome Shell itself, so you won't have Gnome's panel etc anymore.

I wanted a nicer integration between a DE and a WM, and the two nicest options by far have been Xfce and LXQt for me.

LXQt makes it trivial to use your own WM (they use Openbox by default) since they have an option for it in their Preferences [1].

With Xfce however it's a bit more involved [2], since Xfce is more tightly coupled with Xfwm and using a custom WM is not as easy as LXQt makes it.

That said, I'm using Xfce + bspwm for now (as opposed to LXQt + bspwm) mainly because Xfce's display and power manager are more matured than LXQt's.

[0] https://web.archive.org/web/20160726160922/https://awesomewm...

[1] https://wiki.archlinux.org/index.php/LXQt#Replace_Openbox

[2] https://wiki.archlinux.org/index.php/Xfce#Default_window_man...

This is not true, at least not anymore.

Yesod uses xss-sanitize [0], and their sanitize function does indeed prevent "javascript:" attempts. They even have a test case for it [1].

Playing around with it in the REPL:

  Prelude Text.HTML.SanitizeXSS Data.Text> sanitize $ pack "<IMG SRC=javascript:alert('XSS')>"
  "<img>"
  Prelude Text.HTML.SanitizeXSS Data.Text> sanitize $ pack "<IMG SRC=\"javascript:alert('XSS')\">"
  "<img>"
  Prelude Text.HTML.SanitizeXSS Data.Text> sanitize $ pack "<IMG SRC=fine>"
  "<img src=\"fine\">"
  Prelude Text.HTML.SanitizeXSS Data.Text> sanitize $ pack "<IMG SRC=\"this is ok too\">"
  "<img src=\"this is ok too\">"
[0]: https://hackage.haskell.org/package/xss-sanitize

[1] https://github.com/yesodweb/haskell-xss-sanitize/blob/9a9101...

I wrote a long reply, but ended up erasing it and I'll just say that many of these vulnerabilities are due to the programmer using one type (i.e. string) to represent all kinds of data that might be malicious and unsanitized, and then losing track of whether a piece of data is safe for use (e.g. to be sent to DB) or not.

I recommend checking out the Yesod web framework [0], which leverages Haskell's strong type system to provide type-safety and a whole range of nice guarantees, including preventing vulnerabilities like the ones you mentioned.

Spock [1] is another cool web framework also written in Haskell that looks quite promising.

[0] http://www.yesodweb.com/page/about

[1] https://www.spock.li

Not the author (Ruud), but I've been in touch with him.

The source code for his website is free software [0], so feel free to have a look or adopt it for yourself.

Ruud uses a small static site generator he's written in Haskell, and in his own words it “includes a tiny templating engine, an html and css minifier, and an aggressive font subsetter.”

[0] https://github.com/ruuda/blog