MIT licensed by Li-yao Xia
Maintained by lysxia@gmail.com

Module documentation for 0.5.0.0

This version can be pinned in stack with:first-class-families-0.5.0.0@sha256:6e1488c502d5b1e780739a53edab65a307c6bf94d4232fab70e696e87f0fa087,1290

First-class type families Hackage Build Status

For example, consider this simple type family:

type family   FromMaybe (a :: k) (m :: Maybe k) :: k
type instance FromMaybe a 'Nothing  = a
type instance FromMaybe a ('Just b) = b

With first-class-families, it translates to a data declaration and instances for a single Eval family:

import Fcf

data FromMaybe :: k -> Maybe k -> Exp k
type instance Eval (FromMaybe a 'Nothing)  = a
type instance Eval (FromMaybe a ('Just b)) = b

That way, the FromMaybe constructor can be passed to higher-order fcfs.

Eval (Map (FromMaybe 0) '[ 'Just 1, 'Nothing ])  =  '[ 1, 0 ] :: [Nat]

Essential language extensions:

{-# LANGUAGE
    DataKinds,
    PolyKinds,
    TypeFamilies,
    TypeInType,
    TypeOperators,
    UndecidableInstances #-}

See also

Haskell with only one type family (blogpost)


Contributions are welcome. Feel free to open an issue or make a PR on Github!

Changes

0.5.0.0

  • Modularized library

  • Fcf.Utils:

    • Added TError
    • Renamed Collapse to Constraints
  • Fcf.Data.List: Added Cons, Last, Init, Elem

0.4.0.0

  • New functions (blmage)

    • LiftM, LiftM2, LiftM3
    • (<=), (>=), (<), (>)
    • Guarded, Guard((:=)), Otherwise

0.3.0.1

  • GHC 8.6 compatibility

0.3.0.0

  • More new functions, (isovector)

0.2.0.0

  • A whole bunch of basic functions (isovector)
  • Remove Traverse (now Map), BimapPair, BimapEither (now Bimap)

0.1.0.0

Initial version

Depends on 1 package(full list with versions):
comments powered byDisqus