Advertisement
jckuri

ColorTypeEnum.hs

Apr 28th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ColorTypeEnum.hs
  2. -- http://www.haskell.org/haskellwiki/Performance/Data_types#Enumerations
  3. {-# LANGUAGE GeneralizedNewtypeDeriving #-}
  4.  
  5. newtype Color = Color Int deriving (Eq,Ord,Enum)
  6. (red:green:blue:_) = [Color 1 ..]
  7.  
  8. colorInt (Color int) = int
  9.  
  10. main = putStrLn ("List: " ++ show (map colorInt [red,green,blue,green,red]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement