Anonymous records and overloaded labels

Latest on Hackage:0.2.4

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed by Julian K. Arni
Maintained by


Bookkeeper is a new Haskell library that uses the new OverlodaedLabels feature of GHC 8 to provide a new take on datatypes and records:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedLabels #-}
import Bookkeeper

jane :: Book '[ "name" :=> String, "age" :=> Int ]
jane = emptyBook
     & #name =: "Jane"
     & #age =: 30

-- >>> jane
-- Book {age = 30, name = "Jane"}
-- >>> jane ?: #name
-- "Jane"

It bears some similarities to Nikita Volkov's record library, but requires no Template Haskell.

Accesing a field that does not exist is a type error, made nicer with GHCs new custom type errors:

 -- >>> jane ?: #address
--   • The provided Book does not contain the field "address"
--     Book type:
--     '["age" ':-> Int, "name" ':-> String]

The order in which fields are inserted or appear in types does not matter. That is, in:

-- type A = Book '[ "field1" :=> Int,  "field2" :=> Bool]
-- type B = Book '[ "field2" :=> Bool, "field1" :=> Int ]

Types A and B are the same.

You can set, modify, or get fields. See the haddocks for more information.

main :: IO ()
main = return ()



  • Added 'rlens' and lens 'IsLabel' instance.


  • Implement 'fromRecord' for converting values from record.

  • Add 'Data.Default' instance

  • Add 'Gettable', 'Settable', 'Modifiable' type synonyms.

  • Added Eq instance
  • Added Show instance
  • Changed the implementation of 'set' and 'modify'. It no longer needs 'ChooseFirst' to be in scope, and the class constraints changed.
  • Removed 'ChooseFirst'.

  • Initial release
comments powered byDisqus