mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-26 08:27:13 +08:00
15 lines
451 B
Bash
Executable file
15 lines
451 B
Bash
Executable file
#! /usr/bin/env nix-shell
|
|
#! nix-shell -p "haskellPackages.ghcWithPackages (p: [p.containers])"
|
|
#! nix-shell -i runghc
|
|
|
|
import Data.Map
|
|
|
|
m :: Map String Int
|
|
m = fromList [("cats", 3), ("dogs", 2)]
|
|
|
|
main :: IO ()
|
|
main = do
|
|
let cats = findWithDefault 0 "cats" m
|
|
let dogs = findWithDefault 0 "dogs" m
|
|
let zebras = findWithDefault 0 "zebras" m
|
|
print $ "I have " ++ show cats ++ " cats, " ++ show dogs ++ " dogs, and " ++ show zebras ++ " zebras."
|