nix-book/source/recipes/haskell-nixpkg/shebang/my-script.sh
2023-11-28 16:13:05 +00:00

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."