Dictionaries and sets
A number of useful data structures are defined in the containers
package.
Maps¶
Like a Python dictionary, this has unique (and orderable) keys, and arbitrary values. These must be of a single type.
repl example
import qualified Data.Map as M
> hasRedHat = M.fromList [("John", True), ("Sally", False), ("Jane", True)]
> hasRedHat
fromList [("Jane",True),("John",True),("Sally",False)]
> :t hasRedHat
hasRedHat :: M.Map String Bool
> :t M.fromList
M.fromList :: Ord k => [(k, a)] -> M.Map k a
-- look up
> M.lookup "John" hasRedHat
Just True
> M.lookup "Jim" hasRedHat
Nothing
Sets¶
Last update:
February 10, 2023
Created: January 15, 2023
Created: January 15, 2023