From b3fc90629b9c72143451ffb105ebebbb37961bb6 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:35:55 +0100 Subject: [PATCH 1/7] get rid of stupid words --- README.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/README.md b/README.md index e128d8a..aae30a2 100644 --- a/README.md +++ b/README.md @@ -18,22 +18,5 @@ Also provides some useful helpers: * Fast Hashing : [SipHash](https://131002.net/siphash/), [FNV1](http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function). * Built-in base encoding : Base16, Base32, [Base64](http://en.wikipedia.org/wiki/Base64). -Versioning ----------- -Development versions are an incremental number prefixed by 0. -No specific meaning is associated with the versions, specially -no API stability. -Production versions : TBD - -Coding Style ------------- - -The coding style of this project mostly follows: -[haskell-style](https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md) - -Support -------- - -See [Haskell packages guidelines](https://github.com/vincenthz/haskell-pkg-guidelines/blob/master/README.md#support) From 234e0147879fbbded323b0c7a47278bf504361d5 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:37:42 +0100 Subject: [PATCH 2/7] Re-add ci --- .github/workflows/bump.yaml | 28 +++++++ .github/workflows/cabal.yaml | 40 ++++++++++ .github/workflows/nix.yaml | 31 ++++++++ default.nix | 4 + nix/hpkgs.nix | 13 ++++ nix/pkgs.nix | 4 + npins/default.nix | 146 +++++++++++++++++++++++++++++++++++ npins/sources.json | 11 +++ shell.nix | 14 ++++ 9 files changed, 291 insertions(+) create mode 100644 .github/workflows/bump.yaml create mode 100644 .github/workflows/cabal.yaml create mode 100644 .github/workflows/nix.yaml create mode 100644 default.nix create mode 100644 nix/hpkgs.nix create mode 100644 nix/pkgs.nix create mode 100644 npins/default.nix create mode 100644 npins/sources.json create mode 100644 shell.nix diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml new file mode 100644 index 0000000..d417aad --- /dev/null +++ b/.github/workflows/bump.yaml @@ -0,0 +1,28 @@ +# https://github.com/nomeata/haskell-bounds-bump-action +on: + # allows manual triggering from https://github.com/../../actions/workflows/bump.yml + workflow_dispatch: + # runs weekly on Thursday at 8:00 + schedule: + # ┌───────────── minute (0 - 59) + # │ ┌───────────── hour (0 - 23) + # │ │ ┌───────────── day of the month (1 - 31) + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) + # │ │ │ │ │ + # │ │ │ │ │ + # │ │ │ │ │ + # * * * * * + - cron: '0 0 * * 3' + +permissions: + contents: write + pull-requests: write + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - uses: nomeata/haskell-bounds-bump-action@main + with: + test: false diff --git a/.github/workflows/cabal.yaml b/.github/workflows/cabal.yaml new file mode 100644 index 0000000..1bd2b74 --- /dev/null +++ b/.github/workflows/cabal.yaml @@ -0,0 +1,40 @@ +on: + pull_request: + push: + branches: + - master +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + ghc: # should mirror current stable releases: https://www.haskell.org/ghc/download.html + - '9.6' + - '9.8' + os: [ubuntu-latest, macOS-latest, windows-latest] + cabal: ['latest'] + + steps: + - uses: actions/checkout@v3 + - uses: haskell/actions/setup@v2 # https://github.com/haskell/actions/tree/main/setup#haskellactionssetup + with: + ghc-version: ${{ matrix.ghc }} + + - name: Cabal cache + uses: actions/cache@v3 + env: + cache-name: cache-cabal + with: + path: ~/.cabal + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + - name: Cabal update + run: cabal update + - name: Build using cabal + run: cabal build all + - name: Test + run: cabal test all diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml new file mode 100644 index 0000000..ba6acc1 --- /dev/null +++ b/.github/workflows/nix.yaml @@ -0,0 +1,31 @@ +on: + pull_request: + push: + branches: + - master +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Local cache + uses: actions/cache@v5 + with: + path: /nix/store + key: "${{ runner.os }}-nix-cache" + - uses: cachix/install-nix-action@v31 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + + # follow guide: https://nix.dev/tutorials/continuous-integration-github-actions + # this uses the tokens which are revokable + - uses: cachix/cachix-action@v15 + with: + name: jappie + # If you chose API tokens for write access OR if you have a private cache + # authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + - run: nix-build + - run: nix-shell --run "echo OK" diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..da2baed --- /dev/null +++ b/default.nix @@ -0,0 +1,4 @@ +{ hpkgs ? import ./nix/hpkgs.nix {} +, +}: +hpkgs.ram diff --git a/nix/hpkgs.nix b/nix/hpkgs.nix new file mode 100644 index 0000000..b50ce61 --- /dev/null +++ b/nix/hpkgs.nix @@ -0,0 +1,13 @@ +{ pkgs ? import ./pkgs.nix { } +, +}: +# you can pin a specific ghc version with +# pkgs.haskell.packages.ghc984 for example. +# this allows you to create multiple compiler targets via nix. +pkgs.haskellPackages.override { + overrides = hnew: hold: { + # NB this is a bit silly because nix files are now considered for the build + # bigger projects should consider putting haskell stuff in a subfolder + template-project = hnew.callCabal2nix "ram" ../. { }; + }; +} diff --git a/nix/pkgs.nix b/nix/pkgs.nix new file mode 100644 index 0000000..1766122 --- /dev/null +++ b/nix/pkgs.nix @@ -0,0 +1,4 @@ +{ sources ? import ../npins +, +}: +import sources.nixpkgs { } diff --git a/npins/default.nix b/npins/default.nix new file mode 100644 index 0000000..6592476 --- /dev/null +++ b/npins/default.nix @@ -0,0 +1,146 @@ +/* + This file is provided under the MIT licence: + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +# Generated by npins. Do not modify; will be overwritten regularly +let + data = builtins.fromJSON (builtins.readFile ./sources.json); + version = data.version; + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = + first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # If the environment variable NPINS_OVERRIDE_${name} is set, then use + # the path directly as opposed to the fetched source. + # (Taken from Niv for compatibility) + mayOverride = + name: path: + let + envVarName = "NPINS_OVERRIDE_${saneName}"; + saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; + ersatz = builtins.getEnv envVarName; + in + if ersatz == "" then + path + else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" ( + if builtins.substring 0 1 ersatz == "/" then + /. + ersatz + else + /. + builtins.getEnv "PWD" + "/${ersatz}" + ); + + mkSource = + name: spec: + assert spec ? type; + let + path = + if spec.type == "Git" then + mkGitSource spec + else if spec.type == "GitRelease" then + mkGitSource spec + else if spec.type == "PyPi" then + mkPyPiSource spec + else if spec.type == "Channel" then + mkChannelSource spec + else if spec.type == "Tarball" then + mkTarballSource spec + else + builtins.throw "Unknown source type ${spec.type}"; + in + spec // { outPath = mayOverride name path; }; + + mkGitSource = + { + repository, + revision, + url ? null, + submodules, + hash, + branch ? null, + ... + }: + assert repository ? type; + # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository + # In the latter case, there we will always be an url to the tarball + if url != null && !submodules then + builtins.fetchTarball { + inherit url; + sha256 = hash; # FIXME: check nix version & use SRI hashes + } + else + let + url = + if repository.type == "Git" then + repository.url + else if repository.type == "GitHub" then + "https://github.com/${repository.owner}/${repository.repo}.git" + else if repository.type == "GitLab" then + "${repository.server}/${repository.repo_path}.git" + else + throw "Unrecognized repository type ${repository.type}"; + urlToName = + url: rev: + let + matched = builtins.match "^.*/([^/]*)(\\.git)?$" url; + + short = builtins.substring 0 7 rev; + + appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; + in + "${if matched == null then "source" else builtins.head matched}${appendShort}"; + name = urlToName url revision; + in + builtins.fetchGit { + rev = revision; + inherit name; + # hash = hash; + inherit url submodules; + }; + + mkPyPiSource = + { url, hash, ... }: + builtins.fetchurl { + inherit url; + sha256 = hash; + }; + + mkChannelSource = + { url, hash, ... }: + builtins.fetchTarball { + inherit url; + sha256 = hash; + }; + + mkTarballSource = + { + url, + locked_url ? url, + hash, + ... + }: + builtins.fetchTarball { + url = locked_url; + sha256 = hash; + }; +in +if version == 5 then + builtins.mapAttrs mkSource data.pins +else + throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" diff --git a/npins/sources.json b/npins/sources.json new file mode 100644 index 0000000..7ed749b --- /dev/null +++ b/npins/sources.json @@ -0,0 +1,11 @@ +{ + "pins": { + "nixpkgs": { + "type": "Channel", + "name": "nixpkgs-unstable", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre891648.f6b44b240152/nixexprs.tar.xz", + "hash": "0rljaahlkcrcjqd9sj5iyv9zng4yqns1215kanm7hi4w9gri0b74" + } + }, + "version": 5 +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..dfe87e7 --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +{ + hpkgs ? import ./nix/hpkgs.nix {}, + pkgs ? import ./nix/pkgs.nix {}, +}: +hpkgs.shellFor { + packages = ps: [ ps."ram" ]; + withHoogle = false; + + buildInputs = [ + hpkgs.haskell-language-server + pkgs.ghcid + pkgs.cabal-install + ]; +} From 99cfd12f173455880a04715107c291bda9006ef7 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:40:01 +0100 Subject: [PATCH 3/7] Better explain what we're doing --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aae30a2..a560eed 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@ memory [![BSD](http://b.repl.ca/v1/license-BSD-blue.png)](http://en.wikipedia.org/wiki/BSD_licenses) [![Haskell](http://b.repl.ca/v1/language-haskell-lightgrey.png)](http://haskell.org) +This is a fork of memory. It's open to accept changes from anyone, +and aims to use existing well maintained libraries as much as possible. +The fork is necessary because the original maintainer decided to +exit Haskell. + +Note that this is /not/ a redesign of memory. +It's just here to provide stability so +that others can create better alternatives. + Documentation: [ram on hackage](http://hackage.haskell.org/package/ram) A generic memory and related abstraction for haskell: @@ -18,5 +27,3 @@ Also provides some useful helpers: * Fast Hashing : [SipHash](https://131002.net/siphash/), [FNV1](http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function). * Built-in base encoding : Base16, Base32, [Base64](http://en.wikipedia.org/wiki/Base64). - - From 6caa1f610f06ea052cc5366059fa8398cd650877 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:41:06 +0100 Subject: [PATCH 4/7] Fix build --- nix/hpkgs.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/hpkgs.nix b/nix/hpkgs.nix index b50ce61..c30fce2 100644 --- a/nix/hpkgs.nix +++ b/nix/hpkgs.nix @@ -8,6 +8,6 @@ pkgs.haskellPackages.override { overrides = hnew: hold: { # NB this is a bit silly because nix files are now considered for the build # bigger projects should consider putting haskell stuff in a subfolder - template-project = hnew.callCabal2nix "ram" ../. { }; + ram = hnew.callCabal2nix "ram" ../. { }; }; } From 108757617c14a918f60f8ed29362705bf7058828 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:43:05 +0100 Subject: [PATCH 5/7] Fix locations --- ram.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ram.cabal b/ram.cabal index f7c4fd3..6ef0803 100644 --- a/ram.cabal +++ b/ram.cabal @@ -27,13 +27,13 @@ Maintainer: hi@jappie.me Category: memory Stability: experimental Build-Type: Simple -Homepage: https://github.com/vincenthz/hs-memory -Bug-Reports: https://github.com/vincenthz/hs-memory/issues +Homepage: https://github.com/jappeace/ram +Bug-Reports: https://github.com/jappeace/ram/issues extra-doc-files: README.md CHANGELOG.md source-repository head type: git - location: https://github.com/vincenthz/hs-memory + location: https://github.com/jappeace/ram Flag support_bytestring Description: add non-orphan bytearray support for bytestring From b1cc295a03e0fee827596e5c68f0f7d30885c435 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:44:34 +0100 Subject: [PATCH 6/7] upgrade ghc versions in CI --- .github/workflows/cabal.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cabal.yaml b/.github/workflows/cabal.yaml index 1bd2b74..3bd40a2 100644 --- a/.github/workflows/cabal.yaml +++ b/.github/workflows/cabal.yaml @@ -12,8 +12,8 @@ jobs: fail-fast: false matrix: ghc: # should mirror current stable releases: https://www.haskell.org/ghc/download.html - - '9.6' - '9.8' + - '9.10' os: [ubuntu-latest, macOS-latest, windows-latest] cabal: ['latest'] From fb0c1bc7679cc8ef98106103ce08414e36f14bc8 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Sun, 1 Mar 2026 19:47:59 +0100 Subject: [PATCH 7/7] cleanup cabal file --- ram.cabal | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/ram.cabal b/ram.cabal index 6ef0803..4924155 100644 --- a/ram.cabal +++ b/ram.cabal @@ -35,16 +35,6 @@ source-repository head type: git location: https://github.com/jappeace/ram -Flag support_bytestring - Description: add non-orphan bytearray support for bytestring - Default: True - Manual: True - -Flag support_deepseq - Description: add deepseq instances for memory types - Default: True - Manual: True - Library Exposed-modules: Data.ByteArray Data.ByteArray.Encoding @@ -73,11 +63,10 @@ Library Data.ByteArray.MemView Data.ByteArray.View Exposed-modules: Data.ByteArray.Sized - if impl(ghc < 8.8) - buildable: False - else - build-depends: base - , ghc-prim + build-depends: base < 4.23 + , ghc-prim < 0.14 + , bytestring < 0.13 + , deepseq >= 1.1 && < 1.17 -- FIXME armel or mispel is also little endian. -- might be a good idea to also add a runtime autodetect mode. -- ARCH_ENDIAN_UNKNOWN @@ -88,14 +77,6 @@ Library else Other-modules: Data.Memory.MemMap.Posix - -- optional support bytearray instance for bytestring - if flag(support_bytestring) - CPP-options: -DWITH_BYTESTRING_SUPPORT - Build-depends: bytestring - if flag(support_deepseq) - CPP-options: -DWITH_DEEPSEQ_SUPPORT - Build-depends: deepseq >= 1.1 - ghc-options: -Wall -fwarn-tabs default-language: Haskell2010