Serie: haskell
haskell
28 líneas
· Actualizado 2026-02-03
Fruit.hs
haskell/Week9/Fruit.hs
module Fruit where
data Fruit = Apple | Banana | Orange
instance Eq Fruit where
(==) Apple Apple = True
(==) Banana Banana = True
(==) Orange Orange = True
(==) _ _ = False
instance Show Fruit where
show fruit = case fruit of
Apple -> "An apple."
Banana -> "A banana! Yum!"
Orange -> "Yuck, an orange."
instance Ord Fruit where
(<=) Orange Apple = True
(<=) Apple Banana = True
(<=) Orange Banana = True
(<=) Banana Apple = False
(<=) Apple Orange = False
(<=) Banana Orange = False
(<=) Banana Banana = True
(<=) Apple Apple = True
(<=) Orange Orange = True
Artículos relacionados
haskell
haskell
Actualizado 2026-02-03
Adding.hs
Adding.hs — haskell source code from the haskell learning materials (haskell/Adding.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Area.hs
Area.hs — haskell source code from the haskell learning materials (haskell/Area.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Chess.hs
Chess.hs — haskell source code from the haskell learning materials (haskell/Chess.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the haskell learning materials (haskell/ChessGraphics.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Examples.hs
Examples.hs — haskell source code from the haskell learning materials (haskell/Examples.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the haskell learning materials (haskell/Fibonacci.hs).
Leer artículo →