nix-book/source/recipes/shebang/haskell-nixpkg/my-script.sh
Amy de Buitléir 54f4db6d26 expanded
2025-09-05 19:59:37 +01: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."