Using field selectors in a type constructor
Graham Klyne
GK at ninebynine.org
Wed Oct 15 11:47:20 EDT 2003
At 15:03 15/10/03 +1300, Tom Pledger wrote:
>If you're willing to introduce *one* more variable in a let or where,
>try:
>
> joinVarBindings vb1 vb2
> | vbNull vb1 = vb2
> | vbNull vb2 = vb1
> | otherwise = this
> where
> this = VarBinding
> { vbMap = head . filter isJust . flist [ vbMap vb1, vbMap vb2 ]
> , vbEnum = map (\v -> (v,fromJust (vbMap this v))) $
> boundVars vb1 `union` boundVars vb2
> , vbNull = False
> }
Ah, yes, that's neater.
Thanks.
#g
------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact
More information about the Haskell-Cafe
mailing list