The two myAction functions below seem to be equivalent and, for this small 
case, show an interesting economy of code, but being far from a Haskell expert, 
I have to ask, is the first function as small (code wise) as it could be?

Michael


import Control.Applicative

data Color
    = Red
    | Blue
    | Green
    | Yellow
    | Orange
    | Brown
    | Black
    | White
    deriving (Show, Read, Eq, Enum, Ord, Bounded)

-- myAction :: IO Color
-- myAction = getLine
--            >>= \str -> return (read str :: Color)

myAction :: IO Color
myAction = read <$> getLine




      
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to