
15 Jun
2015
15 Jun
'15
10:20 a.m.
Hi. The most robust way to achieve this is to define
{-# LANGUAGE RankNTypes #-}
newtype PolyId = PolyId (forall a. a -> a)
f :: IO PolyId f = return (PolyId id)
main = do PolyId g <- f print $ g 1 print $ g "ciao"
You can also do this more directly using ImpredicativeTypes, but that language extension is quite fragile and not really supported. Cheers, Andres -- Andres Löh, Haskell Consultant Well-Typed LLP, http://www.well-typed.com