[Haskell-cafe] Silly question
Joel Reymont
joelr1 at gmail.com
Mon Oct 31 04:06:21 EST 2005
How do I run z "a" from ghci or the IO monad?
module Foo where
import qualified Data.Map as M
import Control.Monad
import Control.Monad.List
import Prelude hiding ((!!))
(!!) :: (Ord k, MonadPlus m) => [M.Map k v] -> k -> m v
(!!) maps key = msum $ map (M.lookup key) maps
x :: M.Map String Int = M.empty
y :: M.Map String Int = M.fromList [("a", 1)]
z m = [x, y] !! m
Thanks, Joel
--
http://wagerlabs.com/
More information about the Haskell-Cafe
mailing list