Home

About

Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network
FAQHELPSITE MAPCONTACT US


  Advanced Search  

 
Kenneth C. Louden 2003 1 Haskell userHaskell user defined typesdefined types
 

Summary: 3/30/2011
Kenneth C. Louden 2003 1
Haskell userHaskell user defined typesdefined types
data Temp = Cold|Hot|Warm
deriving (Show,Eq, Ord, Enum)
-- to enable printing to screen
-- comparing for equality
i f d h < W-- comparison of order such as x < Warm
-- use in enumerations such as [Cold .. Warm]
termed an enumerated type
Cold and Hot are termed a constructor of type Temp. Constructors must
begin with a capital letter.
data Temp = Hot|Cold|Warm
deriving (Show,Eq)
data Season = Spring|Summer|Fall|Winter
d i i (Sh E )deriving (Show,Eq)
weather Winter = Cold
weather Summer = Hot
weather _ = Warm
:t weather

  

Source: Allan, Vicki H. - Department of Computer Science, Utah State University

 

Collections: Computer Technologies and Information Sciences