[Haskell-cafe] Avoiding the Y combinator for self-referencing types

Florian Weimer fw at deneb.enyo.de
Sun Dec 12 19:43:05 CET 2010


* Miguel Mitrofanov:

> Not sure if that's what you need:
>
> data NodeF f = Node {name :: String, refs :: [f (NodeF f)]}
>
> newtype Const a b = Const a
> newtype Id a = Id a
>
> type NodeS = NodeF (Const String)
> type Node = NodeF Id

Thanks for the suggestion.  Yes, the resulting syntax looks better,
and it is more obvious to me what is going on.



More information about the Haskell-Cafe mailing list