[Haskell-cafe] What *not* to use Haskell for

Reinier Lamers tux_rocker at reinier.de
Wed Nov 12 08:22:22 EST 2008

2008/11/11 Dave Tapley <dukedave at gmail.com>:
> So I should clarify I'm not a troll and do "see the Haskell light". But
> one thing I can never answer when preaching to others is "what does
> Haskell not do well?"

Let's say something controversial: I think that Haskell's type system
gets in your way when you're writing one-shot scripts that don't need
to conform to the highest correctness standards. Imagine typing a
command at the shell prompt and getting the sort of abstract error
message that Haskell compilers give every now and then, like:

> whyerror.lhs:36:25:
>     Ambiguous type variable `a' in the constraint:
>       `Arrow a' arising from use of `>>>' at whyerror.lhs:36:25-27
>     Possible cause: the monomorphism restriction applied to the
> following:
>       liftA2' :: forall b a1 b1 c. (a1 -> b1 -> c) -> a b a1 -> a b
> b1 -> a b c
>         (bound at whyerror.lhs:36:1)
>       unsplit' :: forall a1 b c. (a1 -> b -> c) -> a (a1, b) c
>         (bound at whyerror.lhs:34:1)
>       split' :: forall b. a b (b, b) (bound at whyerror.lhs:33:1)
>     Probable fix: give these definition(s) an explicit type signature
>                   or use -fno-monomorphism-restriction

You don't want to be bothered by such monstrosities (yes, they are,
even though many of you may not see it because of years of
conditioning) when you're just hacking up a simple script to make a
catalog of your MP3 collection / check for patterns in log files /

Also, in my experience Haskell is not so good at data structures where
you can't do structural recursion easily, like graphs. In such cases
you want a language with easy pointers and destructive updates. You
can do those things in pure Haskell by using
the ST monad, but the code will be more verbose than in Java or C++,
and it will occasionally drive you insane with type messages like the
above (You thought you could use '$' freely instead of application?


More information about the Haskell-Cafe mailing list