Paste: discriminated unions

Author: inforichland
Mode: haskell
Date: Mon, 3 Aug 2009 05:46:11
Plain Text |
data Objects = Whiskeybottle | Bucket | Chain | Frog | Wizard | Well
    deriving (Eq, Show, Read)

-- Directions you can walk
data Direction = West | East | Upstairs | Downstairs
    deriving (Eq, Show, Read)

data Room = Garden | Attic | LivingRoom | Inventory
    deriving (Eq, Show, Read)

-- A Path from one place to another, and the entryway
data Path = Path {
    dir :: Direction,
    entryway :: String,
    to :: Room
} deriving (Eq, Show)

-- a location: name, description, and a list of paths to other Locations
data Location = Location {
    name :: Room,
    desc :: String,
    paths :: [Path],
    objects :: [Objects]
} deriving (Eq)

New Annotation

Summary:
Author:
Mode:
Body: