[Haskell-cafe] Sneaky method for var-arg fns?
Brandon Allbery
allbery.b at gmail.com
Sat Jul 27 00:40:49 CEST 2013
On Fri, Jul 26, 2013 at 5:08 PM, Micah Cowan <micah at cowan.name> wrote:
> I was wondering if there was a way to do it in "pure" Haskell (i.e., no
> GHC pragmas required), and also the specific reason for why the above
> example doesn't work without the pragma (I think it's just that in
> general a -> b is not syntactically allowed for type specifiers within
> instance declarations)?
>
The error message you get without the pragma tells you exactly what's
wrong, and that's not it.
Standard Haskell is *very* conservative about what it allows in an instance
declaration; you may not have literal types, nor may you repeat a type
variable, only things of the form (Type var1 var2 ...) are permitted. (The
(String -> String) is not syntactically a problem; it's read as ((->)
String String) which would conform *if* it didn't use literal types. You
can verify this by rephrasing it in prefix form --- note the error message
uses the infix form even if you phrase it as a prefix!) This is widely seen
as unnecessarily restrictive.
--
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://www.haskell.org/pipermail/haskell-cafe/attachments/20130726/444e59bf/attachment.htm>
More information about the Haskell-Cafe
mailing list