summaryrefslogtreecommitdiff
path: root/packages/code
diff options
context:
space:
mode:
Diffstat (limited to 'packages/code')
-rw-r--r--packages/code/hubris/hubris.cabal26
-rw-r--r--packages/code/hubris/shell.nix28
-rw-r--r--packages/code/hubris/src/Hubris/Collections/LRUCache.hs16
3 files changed, 70 insertions, 0 deletions
diff --git a/packages/code/hubris/hubris.cabal b/packages/code/hubris/hubris.cabal
new file mode 100644
index 0000000..dc9c06e
--- /dev/null
+++ b/packages/code/hubris/hubris.cabal
@@ -0,0 +1,26 @@
+cabal-version: 3.14
+name: hubris
+version: 0
+synopsis: Implementations of common data structures
+-- description:
+license: BSD-3-Clause
+license-file: LICENSE
+author: Kleidi Bujari
+maintainer: mail@4kb.net
+-- copyright:
+build-type: Simple
+extra-doc-files: CHANGELOG.md
+-- extra-source-files:
+
+common warnings
+ ghc-options: -Wall
+
+library
+ import: warnings
+ -- other-modules:
+ -- other-extensions:
+ build-depends: base ^>=4.20.2.0,
+ containers >= 0.7
+ hs-source-dirs: src
+ exposed-modules: Hubris.Collections.LRUCache
+ default-language: Haskell2010
diff --git a/packages/code/hubris/shell.nix b/packages/code/hubris/shell.nix
new file mode 100644
index 0000000..0b01f77
--- /dev/null
+++ b/packages/code/hubris/shell.nix
@@ -0,0 +1,28 @@
+{
+ pkgs ? import <nixpkgs> { },
+ ...
+}:
+
+pkgs.mkShell {
+ packages = with pkgs; [
+ (haskellPackages.ghc.withPackages (p: [
+ p.cabal-install
+ p.haskell-language-server
+ p.hasktags
+ p.hoogle
+ p.megaparsec
+ p.hakyll
+ p.pqueue
+ ]))
+ ];
+
+ nativeBuildInputs = with pkgs; [
+ ormolu
+ typst
+ ];
+
+ buildInputs = with pkgs; [
+ pkg-config
+ zlib
+ ];
+}
diff --git a/packages/code/hubris/src/Hubris/Collections/LRUCache.hs b/packages/code/hubris/src/Hubris/Collections/LRUCache.hs
new file mode 100644
index 0000000..995512d
--- /dev/null
+++ b/packages/code/hubris/src/Hubris/Collections/LRUCache.hs
@@ -0,0 +1,16 @@
+module Hubris.Collections.LRUCache
+ ( empty
+ , insert
+ ) where
+
+import qualified Data.Map as M
+import Data.Monoid (Sum (..))
+
+type LRUCache a = M.Map a (Sum Int)
+
+empty :: LRUCache a
+empty = M.empty
+
+insert :: a -> LRUCache a -> LRUCache a
+insert = M.alter (fmap $ const 0)
+ where