From 017f47a83b7b1d8f32982f58e688802735b14e9f Mon Sep 17 00:00:00 2001 From: Kleidi Bujari Date: Thu, 23 Jul 2026 11:25:39 -0700 Subject: . --- .gitignore | 2 +- packages/code/hubris/hubris.cabal | 26 ++++++++++++++++++++ packages/code/hubris/shell.nix | 28 ++++++++++++++++++++++ .../code/hubris/src/Hubris/Collections/LRUCache.hs | 16 +++++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 packages/code/hubris/hubris.cabal create mode 100644 packages/code/hubris/shell.nix create mode 100644 packages/code/hubris/src/Hubris/Collections/LRUCache.hs diff --git a/.gitignore b/.gitignore index 278647f..857484e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ result* .direnv/ # haskell cache -dist-newstyle/ \ No newline at end of file +dist-newstyle/ 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 { }, + ... +}: + +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 -- cgit v1.3.1