[Haskell] [newbye] 'Just a'
Yuri D'Elia
wavexx at yuv.info
Fri Feb 4 13:33:41 EST 2005
Hi all. I'm experimenting with haskell and its type system.
I've done a function which scans a list, and returns "Just a"
value if the element is found, or Nothing.
get :: a -> Maybe a
and implemented
getAorB :: Maybe a -> Maybe a -> a
getAorB a b = ...
a function which returns "Just (get a)" or "Just (get b)" if (get a) is
Nothing (excluding failures in both). By now, I've implemented it in
terms of pattern matching:
getAorB a b = f (get a) (get b)
where f (Just a) Nothing = a
f Nothing (Just a) = a
but I'd like to know if there are other possible ways to do it, possibly
without enforcing an evaluation order like pattern matching does.
More information about the Haskell
mailing list