okasaki

Okasaki's Purely Functional Data Structures
Log | Files | Refs | LICENSE

commit 0d2742da34d275aa453a7c2418bb7a37e4d46cd5
parent 75ec43de2138dbbfdbd964f30ea1de74734074d9
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 10 Dec 2022 16:43:41 -0330

Better nixification.

Diffstat:
M.gitignore | 3+--
Adefault.nix | 34++++++++++++++++++++++++++++++++++
Mlib/Okasaki/Stack.hs | 1+
Mlib/Okasaki/Tree.hs | 3++-
Mokasaki.cabal | 1+
Ashell.nix | 1+
6 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,5 +1,4 @@ .cabal-sandbox cabal.sandbox.config -dist +dist-newstyle *swp -.stack-work diff --git a/default.nix b/default.nix @@ -0,0 +1,34 @@ +let + revision = "813836d64"; + + tarball = owner: repo: rev: + builtins.fetchTarball { + url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; + }; + + compilerSet = pkgs.haskell.packages."ghc902"; + + pkgs = import (tarball "NixOS" "nixpkgs" revision) { inherit config; }; + ignore = pkgs.nix-gitignore.gitignoreSourcePure; + + config = { + packageOverrides = super: let self = super.pkgs; in rec { + haskell = super.haskell // { + packageOverrides = self: super: { + okasaki = super.callCabal2nix "okasaki" + (ignore [./.gitignore] ./.) {}; + }; + }; + }; + }; + +in + { + inherit pkgs; + shell = compilerSet.shellFor { + packages = p: [p.okasaki]; + buildInputs = with pkgs; [ + compilerSet.cabal-install + ]; + }; + } diff --git a/lib/Okasaki/Stack.hs b/lib/Okasaki/Stack.hs @@ -23,6 +23,7 @@ module Okasaki.Stack ( ) where import Prelude hiding (head, tail) +import Data.Fix (Fix(..)) import Data.Functor.Foldable as RS import Text.Show.Deriving diff --git a/lib/Okasaki/Tree.hs b/lib/Okasaki/Tree.hs @@ -16,6 +16,7 @@ module Okasaki.Tree ( , fromList ) where +import Data.Fix (Fix(..), unFix) import Data.Functor.Foldable import Text.Show.Deriving @@ -36,7 +37,7 @@ node x l r = Fix (NodeF l x r) insert :: Ord a => a -> Tree a -> Tree a insert x = apo coalg where - coalg input = case unfix input of + coalg input = case unFix input of LeafF -> NodeF (Left leaf) x (Left leaf) NodeF l e r -> case compare x e of EQ -> NodeF (Left l) e (Left r) diff --git a/okasaki.cabal b/okasaki.cabal @@ -17,6 +17,7 @@ library , Okasaki.Tree build-depends: base + , data-fix , deriving-compat , recursion-schemes diff --git a/shell.nix b/shell.nix @@ -0,0 +1 @@ +(import ./default.nix).shell