[Haskell-cafe] Re: nested maybes

Max Vasin max.vasin at gmail.com
Sun Feb 4 13:13:33 EST 2007


> Maybe has a Monad instance, so you can write this as follows (untested):

> exists str wmap = boolFromMaybe exists'
>   where exists' =
>             do x <- Map.lookup (sort str) wmap
>                find (== str) (snd x)
>         boolFromMaybe (Just _) = True
>         boolFromMaybe Nothing  = False

import isJust
boolFromMaybe = isJust

-- 
WBR,
Max Vasin.



More information about the Haskell-Cafe mailing list