Haskell is sandbox crack!

Mar 17, 2009 16:20

I've been spending my Copious Free Time lately trying to implement a simple dynamically-typed language in Haskell, both because I like this kind of programming and to make me a better Haskell programmer. Learning Haskell isn't like learning most other programming languages. With most programming languages, you work with the language for a few ( Read more... )

Leave a comment

Comments 3

well said anonymous May 13 2009, 22:03:02 UTC
i am a haskell newbie but even so i get what you mean. word!

Reply


Monads anonymous July 14 2010, 03:14:07 UTC
Just wanted to point out that Writer and Reader don't do what your post says they do, i.e. allow writing or reading (respectively) of streams. Writer lets you accumulate data into a monoidal structure (often a list); Reader gives all code in that monad read-only access to a chunk of data without having to explicitly pass it around.

Also, ST and State are slightly different than what you describe. The ST monad lets you write imperative code (which is why it runs in the IO monad). You can create and manipulate arrays and memory references. The State monad is completely different - it's a pure, I/O free monad that simply saves you the time of passing arguments in and then reading them back out. State is really just a convenient way of passing a small piece of data between functions - it's not really mutation.

Reply

Re: Monads mvanier July 18 2010, 00:11:26 UTC
You're right about Writer and Reader, though I was thinking more of how they are used (i.e. this is conceptually what they do, not literally).

As for ST and State, again, you're right but I stand by my way of describing them. State is as you say purely functional, whereas ST is no more functional than IO is. Nevertheless, the reason you choose to use State rather than ST (at least, the reason I have done so) is because the stateful data you're passing around is fixed (a small bounded number of stateful items), whereas with ST you can create e.g. all the STRefs you like. OTOH I can imagine situations where you might pick ST over State for efficiency reasons, or alternatively you could use e.g. a list in the State monad to accumulate an unbounded number of items.

Reply


Leave a comment

Up