first-class-families: First class type families

[ library, mit, other ] [ Propose Tags ]

First class type families, eval-style defunctionalization

See Fcf.


[Skip to Readme]
Versions 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.3.0.1, 0.4.0.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <4.13) [details]
License MIT
Copyright 2018 Li-yao Xia
Author Li-yao Xia
Maintainer lysxia@gmail.com
Revised Revision 1 made by lyxia at Fri Jan 11 10:55:09 UTC 2019
Category Other
Home page https://github.com/Lysxia/first-class-families#readme
Source repo head: git clone https://github.com/Lysxia/first-class-families
Uploaded by lyxia at Sun Dec 30 15:57:10 UTC 2018
Distributions LTSHaskell:0.3.0.1, NixOS:0.4.0.0, Stackage:0.4.0.0
Downloads 318 total (125 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2018-12-30 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for first-class-families-0.4.0.0

[back to package description]

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!