#2309: containers: specialize functions that fail in a Monad to Maybe

Evan Laforge qdunkan at gmail.com
Wed May 28 21:43:20 EDT 2008

> Following this line of reasoning: why is  1  syntactic sugar for
>  fromIntegral 1? If 1 has type Integer then the generic value is just a
> fromIntergal away!
> If we can make a function more convenient to use by making it more generic,
> I see no reason not to do so, as long as things remain safe.

>From my point of view, the automatic fromIntegral *does* cause
confusion (wasn't there a question wondering about that just
recently?).  However, it's so common to want integer-looking literals
to actually be Ints or Doubles or something that the convenience
outweighs the extra complexity.

What some people seem to be saying is that using lookup with some
other monad is just not common enough for it to be worth the extra
complexity.  I always use it with Maybe myself, and I'm all for
keeping things concrete unless there's a need.  I see the point about
lifts though and could imagine maybe someone has some pattern where
they use their own monad a lot and lifts would be a hassle...  but
that's just "imagine" for me :)

Also, I wouldn't say more generic (or rather, less explicit lifting
needed) is really totally "free"... it always looks more complicated
when you see some polymorphic typeclass constrained type constructor
parameter vs. a monomorphic concrete one.  And I think even just
*looking* simple is important!

More information about the Libraries mailing list