[Haskell-cafe] Flipping *->*->* kinds, or monadic finally-tagless madness

wren ng thornton wren at freegeek.org
Sat Jul 4 00:33:14 EDT 2009


Kim-Ee Yeoh wrote:
 > > type VarCount = int
 > > newtype Y b a = Y {unY :: VarCount -> (b, VarCount)}
 >
> Hi Edward,
> 
> Your runPretty version fits the bill nicely, thank you. I might still retain
> the state monad version because it allows generalizations beyond
> pretty-printing.
> 
> As for fixing the original bug, I've found that the real magic lies
> in the incantation (Y . unY) inserted at the appropriate places.

Aka unsafeCoerce, changing the phantom type |a|. The need to do it is 
caused by wanting to erase the existential introduced by Za/MkZa. 
Depending on what the phantom type is supposed to represent, this may or 
may not give the semantics/safety you're after.

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list