RankNTypes question

Hi Cafe, I can't find how can I do this: {-# LANGUAGE RankNTypes #-} example :: forall a. (forall b. b) -> a example = undefined The first `forall` is for cosmetic reasons. If I understand correctly this is a safe and legit function (please correct me if I'm wrong!). I thought that I can just define `example = id` and GHC would do the rest, but alas, that didn't happen. Thanks! -- Nikolay.

Ah sorry, I think I responded only to you, not to the whole list. If anyone else is interested, my answer was: test :: (forall a. a -> a) -> Int -> Int test f a = f a Also consider this: foo :: Maybe a -> Maybe b foo Nothing = Nothing vs. foo :: Maybe a -> Maybe b fooo a@Nothing = a You don't actually need RankNTypes to bump into this. Don't feel stupid, I remember running into this kind of things frequently when I was trying to define Prisms (from lens) by hand ;) Kind regards, Marcin Mrotek
participants (2)
-
Marcin Mrotek
-
Nikolay Amiantov