The idea is that fs accepts a polymorphic function as its argument.
What type signature can I specify for f in order to compile this code?

As you said yourself, you need to add a type signature to fs:

{-# LANGUAGE RankNTypes #-}


fs :: ((forall a . ((a, a) -> a)) -> t) -> (t, t)
fs g = (g fst, g snd)

examples = (fs id, fs repeat, fs (\x -> [x]), fs ((,)id))


Hope this helps,

  Wouter


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to