[Haskell] Re: Using implicit parameter constraints in data decl
Benjamin Franksen
benjamin.franksen at bessy.de
Mon Nov 8 18:04:37 EST 2004
On Sunday 07 November 2004 19:36, Benjamin Franksen wrote:
>
> data (?val::Bool) => Test = Test { name :: String }
>
> is rejected by the compiler
> [...]
> which is unfortunate since it means that you cannot put a function that
> depends on an implicit parameter into a data structure. There are probably
> technical reasons for this restriction, but it means that such functions
> are no longer first class objects.
Here is an executive summary lest anyone gets false ideas:
Functions with implicit parameters *are* first class values but only if you
use -fglasgow-exts and not only -fimplicit-params. The version above is
rejected nonetheless (for whatever reason I can't figure out at the moment)
but
data Test = Test { name :: (?val::Bool) => String }
works. The compiler flag is needed because in Haskel98 contexts may not appear
after the 'data' (i.e. the way I tried it at first) and -fglasgow-exts lifts
this restriction. I haven't found this explicitly mentioned in the ghc docs,
but that doesn't mean it's not there somewhere.
References:
http://www.haskell.org/onlinelibrary/decls.html
Thanks to Ben Rudiak-Gould who helped me to resolve this.
Cheers,
Ben
--
Top level things with identity are evil. -- Lennart Augustsson
More information about the Haskell
mailing list