membrain: Type-safe memory units

[ library, memory, mpl, safe ] [ Propose Tags ]

membrain provides newtype wrapper for type-safe work with memory units

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

This data type stores memory unit value phantom type parameter which is represented as type-level natural number. The ideas behind this package are described in the following blog post:


[Skip to Readme]
Versions [faq] 0.0.0.0
Change log CHANGELOG.md
Dependencies base (>=4.10.1.0 && <4.13) [details]
License MPL-2.0
Copyright 2018-2019 Kowainik
Author Veronika Romashkina, Dmitrii Kovanikov
Maintainer Kowainik <xrom.xkov@gmail.com>
Category Memory, Safe
Home page https://github.com/kowainik/membrain
Bug tracker https://github.com/kowainik/membrain/issues
Source repo head: git clone https://github.com/kowainik/membrain.git
Uploaded by vrom911 at Tue Jul 23 12:06:26 UTC 2019
Distributions NixOS:0.0.0.0
Downloads 29 total (11 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-07-23 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for membrain-0.0.0.0

[back to package description]

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.