{- Carrie's Candy Bowl, Code Skeleton (List Representation)
H. Conrad Cunningham
1234567890123456789012345678901234567890123456789012345678901234567890
2018-10-21: Expanded from similar previous work
Notes:
- In some cases, you may need to restrict the polymorphism to
implement a function. Be careful not to restrict functions
unnecessarily.
- You may find Prelude functions such as concatMap, elem, filter,
length, map, null, replicate, and span useful.
- You may also find functions in the Data.List library
useful -- e.g. sort, group, and (\\).
-}
module CandyBowl_list
( CandyBowl(..), newBowl, putIn, takeOut, isEmpty, size, howMany,
has, eqBowl, inventory, restock, combine, difference, rename
)
where
-- Used in instructor solution
-- import Data.List ( sort, group, (\\) )
-- Candy bowl data representation
data CandyBowl a = Bowl [a] deriving Show
-- Remove comments from implemented type signatures below
-- Exercise #1
-- newBowl :: CandyBowl a
-- Exercise #2
-- isEmpty :: CandyBowl a -> Bool
-- Exercise #3
-- putIn :: CandyBowl a -> a -> CandyBowl a
-- Exercise #4
-- has :: Eq a => CandyBowl a -> a -> Bool
-- Exercise #5
-- size :: CandyBowl a -> Int
-- Exercise #6
-- howMany :: Eq a => CandyBowl a -> a -> Int
-- Exercise #7
-- takeOut :: (Eq a,Show a) => CandyBowl a -> a -> Maybe (CandyBowl a)
-- Exercise #8
-- eqBowl :: Ord a => CandyBowl a -> CandyBowl a -> Bool
-- Exercise #9
-- inventory :: Ord a => CandyBowl a -> [(a,Int)]
-- Exercise #10
-- restock :: [(a,Int)] -> CandyBowl a
-- Exercise #11
-- combine :: CandyBowl a -> CandyBowl a -> CandyBowl a
-- Exercise #12
-- difference :: Eq a => CandyBowl a -> CandyBowl a -> CandyBowl a
-- Exercise #13
-- rename :: CandyBowl a -> (a -> b) -> CandyBowl b