Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions .github/workflows/cabal.yaml
Original file line number Diff line number Diff line change
@@ -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.8'
- '9.10'
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
31 changes: 31 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -18,22 +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).

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)
4 changes: 4 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ hpkgs ? import ./nix/hpkgs.nix {}
,
}:
hpkgs.ram
13 changes: 13 additions & 0 deletions nix/hpkgs.nix
Original file line number Diff line number Diff line change
@@ -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
ram = hnew.callCabal2nix "ram" ../. { };
};
}
4 changes: 4 additions & 0 deletions nix/pkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ sources ? import ../npins
,
}:
import sources.nixpkgs { }
146 changes: 146 additions & 0 deletions npins/default.nix
Original file line number Diff line number Diff line change
@@ -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`"
11 changes: 11 additions & 0 deletions npins/sources.json
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 7 additions & 26 deletions ram.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +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

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
location: https://github.com/jappeace/ram

Library
Exposed-modules: Data.ByteArray
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
14 changes: 14 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -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
];
}
Loading