Skip to content
🧠 Type-safe memory units
Haskell
Branch: master
Clone or download
Pull request Compare This branch is 2 commits behind kowainik:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.ghci
.gitignore
.stylish-haskell.yaml
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
membrain.cabal
stack.yaml

README.md

membrain

memory-brain Build status Hackage Stackage Lts Stackage Nightly MPL-2.0 license

"People think dreams aren't real just because they aren't made of matter, of particles. Dreams are real. But they are made of viewpoints, of images, of memories and puns and lost hopes."

― Neil Gaiman

This package implements type-safe memory units. It pursues the following goals:

  1. Focus on correctness.
  2. Low amount of boilerplate should be required to use the library.

The ideas behind this package are described in the following blog post:

The library is built around the following data type:

newtype Memory (mem :: Nat) = Memory
    { unMemory :: Natural
    }

This data type stores every memory internally as bits. However, unit multiplier is stored as type-level natural number. This approach allows to represent different units and implement instances for them with low amount of boilerplate.

membrain implements various useful functions to work with Memory:

  1. Smart constructors.
  2. Conversion functions.
  3. Pretty displaying.
  4. Dependently-typed parsing.
  5. Numeric functions.
  6. Type-safe wrappers around functions from base.

Acknowledgement

Icons made by Kiranshastry from Flaticon is licensed by CC 3.0 BY.

You can’t perform that action at this time.