Craft3e-0.2.0.1: Code for Haskell: the Craft of Functional Programming, 3rd ed.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Chapter14_2

Synopsis

Documentation

data Pairs a Source #

^^^^^^^^^^^^^^^^^^^^^^

^^^^^^^^^^^^^^^^^^^^^^^^^^

Constructors

Pr a a 

equalPair :: Eq a => Pairs a -> Bool Source #

^^^^

data List a Source #

^^^^^^^^^^^

Constructors

NilL 
a ::: (List a) infixr 5 

Instances

Instances details
Read a => Read (List a) Source # 
Instance details

Defined in Chapter14_2

Show a => Show (List a) Source # 
Instance details

Defined in Chapter14_2

Methods

showsPrec :: Int -> List a -> ShowS #

show :: List a -> String #

showList :: [List a] -> ShowS #

Eq a => Eq (List a) Source # 
Instance details

Defined in Chapter14_2

Methods

(==) :: List a -> List a -> Bool #

(/=) :: List a -> List a -> Bool #

Ord a => Ord (List a) Source # 
Instance details

Defined in Chapter14_2

Methods

compare :: List a -> List a -> Ordering #

(<) :: List a -> List a -> Bool #

(<=) :: List a -> List a -> Bool #

(>) :: List a -> List a -> Bool #

(>=) :: List a -> List a -> Bool #

max :: List a -> List a -> List a #

min :: List a -> List a -> List a #

data Tree a Source #

Constructors

Nil 
Node a (Tree a) (Tree a) 

Instances

Instances details
Arbitrary a => Arbitrary (Tree a) Source # 
Instance details

Defined in Chapter14_2

Methods

arbitrary :: Gen (Tree a) #

shrink :: Tree a -> [Tree a] #

Read a => Read (Tree a) Source # 
Instance details

Defined in Chapter14_2

Show a => Show (Tree a) Source # 
Instance details

Defined in Chapter14_2

Methods

showsPrec :: Int -> Tree a -> ShowS #

show :: Tree a -> String #

showList :: [Tree a] -> ShowS #

Eq a => Eq (Tree a) Source # 
Instance details

Defined in Chapter14_2

Methods

(==) :: Tree a -> Tree a -> Bool #

(/=) :: Tree a -> Tree a -> Bool #

Ord a => Ord (Tree a) Source # 
Instance details

Defined in Chapter14_2

Methods

compare :: Tree a -> Tree a -> Ordering #

(<) :: Tree a -> Tree a -> Bool #

(<=) :: Tree a -> Tree a -> Bool #

(>) :: Tree a -> Tree a -> Bool #

(>=) :: Tree a -> Tree a -> Bool #

max :: Tree a -> Tree a -> Tree a #

min :: Tree a -> Tree a -> Tree a #

collapse :: Tree a -> [a] Source #

mapTree :: (a -> b) -> Tree a -> Tree b Source #

^^^^^^^^^^^^^^^^^^^^^

data Either a b Source #

Constructors

Left a 
Right b 

Instances

Instances details
(Read a, Read b) => Read (Either a b) Source # 
Instance details

Defined in Chapter14_2

(Show a, Show b) => Show (Either a b) Source # 
Instance details

Defined in Chapter14_2

Methods

showsPrec :: Int -> Either a b -> ShowS #

show :: Either a b -> String #

showList :: [Either a b] -> ShowS #

(Eq a, Eq b) => Eq (Either a b) Source # 
Instance details

Defined in Chapter14_2

Methods

(==) :: Either a b -> Either a b -> Bool #

(/=) :: Either a b -> Either a b -> Bool #

(Ord a, Ord b) => Ord (Either a b) Source # 
Instance details

Defined in Chapter14_2

Methods

compare :: Either a b -> Either a b -> Ordering #

(<) :: Either a b -> Either a b -> Bool #

(<=) :: Either a b -> Either a b -> Bool #

(>) :: Either a b -> Either a b -> Bool #

(>=) :: Either a b -> Either a b -> Bool #

max :: Either a b -> Either a b -> Either a b #

min :: Either a b -> Either a b -> Either a b #

either :: (a -> c) -> (b -> c) -> Either a b -> c Source #

applyLeft :: (a -> c) -> Either a b -> c Source #

data GTree a Source #

^^^^^^^^^^^^^^^^^^^^^^^^^

Constructors

Leaf a 
Gnode [GTree a] 

tl :: [a] -> [a] Source #

hd :: a -> [a] -> a Source #

^^^^^^^^^^

data Maybe a Source #

Constructors

Nothing 
Just a 

Instances

Instances details
Read a => Read (Maybe a) Source # 
Instance details

Defined in Chapter14_2

Show a => Show (Maybe a) Source # 
Instance details

Defined in Chapter14_2

Methods

showsPrec :: Int -> Maybe a -> ShowS #

show :: Maybe a -> String #

showList :: [Maybe a] -> ShowS #

Eq a => Eq (Maybe a) Source # 
Instance details

Defined in Chapter14_2

Methods

(==) :: Maybe a -> Maybe a -> Bool #

(/=) :: Maybe a -> Maybe a -> Bool #

Ord a => Ord (Maybe a) Source # 
Instance details

Defined in Chapter14_2

Methods

compare :: Maybe a -> Maybe a -> Ordering #

(<) :: Maybe a -> Maybe a -> Bool #

(<=) :: Maybe a -> Maybe a -> Bool #

(>) :: Maybe a -> Maybe a -> Bool #

(>=) :: Maybe a -> Maybe a -> Bool #

max :: Maybe a -> Maybe a -> Maybe a #

min :: Maybe a -> Maybe a -> Maybe a #

mapMaybe :: (a -> b) -> Maybe a -> Maybe b Source #

maybe :: b -> (a -> b) -> Maybe a -> b Source #

data Err a Source #

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

^^^^^^^^^^^^^^^^^^^^^^^^

Constructors

OK a 
Error String 

data Edit Source #

Constructors

Change Char 
Copy 
Delete 
Insert Char 
Kill 

Instances

Instances details
Show Edit Source # 
Instance details

Defined in Chapter14_2

Methods

showsPrec :: Int -> Edit -> ShowS #

show :: Edit -> String #

showList :: [Edit] -> ShowS #

Eq Edit Source # 
Instance details

Defined in Chapter14_2

Methods

(==) :: Edit -> Edit -> Bool #

(/=) :: Edit -> Edit -> Bool #

best :: [[Edit]] -> [Edit] Source #

cost :: [Edit] -> Int Source #

edit :: [Edit] -> String -> String Source #

^^^^^^^^^

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

^^^^^^^^^^^^^^

data Vector Source #

Constructors

Vec Float Float 

class Movable a where Source #

Minimal complete definition

move, reflectX, reflectY

Methods

move :: Vector -> a -> a Source #

reflectX :: a -> a Source #

reflectY :: a -> a Source #

rotate180 :: a -> a Source #

Instances

Instances details
Movable Figure Source # 
Instance details

Defined in Chapter14_2

Movable Point Source # 
Instance details

Defined in Chapter14_2

Movable a => Movable (Name a) Source # 
Instance details

Defined in Chapter14_2

Methods

move :: Vector -> Name a -> Name a Source #

reflectX :: Name a -> Name a Source #

reflectY :: Name a -> Name a Source #

rotate180 :: Name a -> Name a Source #

Movable a => Movable [a] Source #

^^^^^^^^^^^^

Instance details

Defined in Chapter14_2

Methods

move :: Vector -> [a] -> [a] Source #

reflectX :: [a] -> [a] Source #

reflectY :: [a] -> [a] Source #

rotate180 :: [a] -> [a] Source #

data Point Source #

Constructors

Point Float Float 

Instances

Instances details
Movable Point Source # 
Instance details

Defined in Chapter14_2

Show Point Source # 
Instance details

Defined in Chapter14_2

Methods

showsPrec :: Int -> Point -> ShowS #

show :: Point -> String #

showList :: [Point] -> ShowS #

data Figure Source #

Constructors

Line Point Point 
Circle Point Float 

Instances

Instances details
Movable Figure Source # 
Instance details

Defined in Chapter14_2

Show Figure Source # 
Instance details

Defined in Chapter14_2

class Named a where Source #

Methods

lookName :: a -> String Source #

giveName :: String -> a -> a Source #

Instances

Instances details
Named (Name a) Source #

^^^^^^^^^^^^^^^^^^^^^^^

Instance details

Defined in Chapter14_2

Methods

lookName :: Name a -> String Source #

giveName :: String -> Name a -> Name a Source #

data Name a Source #

Constructors

Pair a String 

Instances

Instances details
Movable a => Movable (Name a) Source # 
Instance details

Defined in Chapter14_2

Methods

move :: Vector -> Name a -> Name a Source #

reflectX :: Name a -> Name a Source #

reflectY :: Name a -> Name a Source #

rotate180 :: Name a -> Name a Source #

Named (Name a) Source #

^^^^^^^^^^^^^^^^^^^^^^^

Instance details

Defined in Chapter14_2

Methods

lookName :: Name a -> String Source #

giveName :: String -> Name a -> Name a Source #

Movable a => NamedMovable (Name a) Source #

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Instance details

Defined in Chapter14_2

mapName :: (a -> b) -> Name a -> Name b Source #

class (Movable b, Named b) => NamedMovable b Source #

Instances

Instances details
Movable a => NamedMovable (Name a) Source #

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Instance details

Defined in Chapter14_2

prop_collapse :: Eq b => (a -> b) -> Tree a -> Bool Source #