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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to