mirror of
https://github.com/Lysxia/first-class-families.git
synced 2024-09-11 19:47:12 +03:00
Microdoc
This commit is contained in:
parent
45484e1996
commit
5c0b4c86b2
@ -1 +1,8 @@
|
||||
# First-class type families
|
||||
|
||||
See `src/Fcf`.
|
||||
|
||||
---
|
||||
|
||||
Contributions are welcome. Feel free to open an issue or make a PR on
|
||||
[Github](https://github.com/Lysxia/first-class-families)!
|
||||
|
@ -5,6 +5,8 @@ synopsis:
|
||||
description:
|
||||
First class type families,
|
||||
eval-style defunctionalization
|
||||
.
|
||||
See "Fcf".
|
||||
homepage: https://github.com/Lysxia/first-class-families#readme
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
|
21
src/Fcf.hs
21
src/Fcf.hs
@ -7,6 +7,27 @@
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
|
||||
-- | First-class type families
|
||||
--
|
||||
-- For example, here is a regular 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 @Fcf@, it translates to a @data@ declaration:
|
||||
--
|
||||
-- @
|
||||
-- data FromMaybe :: k -> Maybe k -> 'Exp' k
|
||||
-- type instance 'Eval' (FromMaybe a 'Nothing) = a
|
||||
-- type instance 'Eval' (FromMaybe a ('Just b)) = b
|
||||
-- @
|
||||
--
|
||||
-- - Fcfs can be higher-order.
|
||||
-- - The kind constructor 'Exp' is a monad: there's @('=<<')@ and 'Pure'.
|
||||
|
||||
module Fcf where
|
||||
|
||||
import Data.Kind (Type)
|
||||
|
Loading…
Reference in New Issue
Block a user