This commit is contained in:
Amy de Buitléir 2025-09-13 20:44:16 +01:00
parent 595d08319e
commit cc0d0228cd
7 changed files with 133 additions and 440 deletions

View file

@ -28,6 +28,22 @@ Here's a short Haskell program that uses it.
include::Main.hs[]
....
REDO containers is there by default
REDO containers is there by default
REDO containers is there by default
REDO containers is there by default
REDO containers is there by default
REDO containers is there by default
REDO containers is there by default
REDO containers is there by default
Here's a demonstration using the program.
....

View file

@ -0,0 +1,11 @@
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."

View file

@ -0,0 +1,60 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1757790242,
"narHash": "sha256-53ib4nvwVVAYF1ipe7BBEwjvvBo0lEbQcsbCHPSfzAg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "38cbd6b3be3ce84eb389eabb552dff8824019d2b",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,21 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
customGhc = pkgs.haskellPackages.ghcWithPackages (p: with p; [ containers ]);
in
{
devShells = rec {
default = pkgs.mkShell {
buildInputs = [ customGhc ];
};
};
}
);
}