@hackage overloaded-records0.1.0.0

Overloaded Records based on current GHC proposal.

Overloaded Records

Hackage Hackage Dependencies Haskell Programming Language BSD3 License

Build

Description

Implementation of /Overloaded Records/ based on current GHC proposal.

This implementation is highly experimental and may change rapidly.

More about the current status of OverloadedRecordFields language extension can be found on GHC Wiki: OverloadedRecordFields.

Usage Example

{-# LANGUAGE DataKinds #-}              -- overloadedRecords, labels
{-# LANGUAGE FlexibleContexts #-}       -- labels
{-# LANGUAGE FlexibleInstances #-}      -- overloadedRecords
{-# LANGUAGE MultiParamTypeClasses #-}  -- overloadedRecords
{-# LANGUAGE TemplateHaskell #-}        -- overloadedRecords, labels
{-# LANGUAGE TypeFamilies #-}           -- overloadedRecords
module FooBar
  where

import Data.Default.Class (Default(def))

import Data.OverloadedRecords.TH (overloadedRecords)
import Data.OverloadedLabels.TH (label, labels)


data Foo a = Foo
    { _x :: Int
    , _y :: a
    }

overloadedRecords def ''Foo
labels ["x", "y"]

newtype Bar a = Bar {_bar :: a}

overloadedRecords def ''Bar
label "bar"

License

The BSD 3-Clause License, see LICENSE file for details. This implementation is based on original prototype, which is under MIT License.

Contributions

Contributions, pull requests and bug reports are welcome! Please don't be afraid to contact author using GitHub or by e-mail.