[Haskell-cafe] (Why) must this function remain nameless?

Brandon Allbery allbery.b at gmail.com
Thu May 28 19:29:06 UTC 2015


On Tue, May 26, 2015 at 12:31 AM, Clinton Mead <clintonmead at gmail.com>
wrote:

> The following code (somewhat contrived) code compiles on GHC without
> issue, and towards the end repeatedly uses the lambda function "(\fn (D x)
> -> f fn x)". But when I simply try to give it a name, like so:
>
> h = (\fn (D x) -> f fn x)
>
> I then get a compile error.
>

That's inviting the monomorphism restriction to become involved, as a top
level binding without a parameter (the parameter is explicitly part of its
value). If that is the issue, writing it as

    h fn (D x) = f fn x

would work better.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150528/8a434ac9/attachment.html>


More information about the Haskell-Cafe mailing list