Created
March 2, 2019 20:48
-
-
Save i-am-tom/462b10a67dde895f6ce2b982553ee56a to your computer and use it in GitHub Desktop.
Visible quantification???
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeInType #-} | |
module Data.Whole where | |
import Data.Kind (Type) | |
data Sign = Positive | Negative | |
data Whole :: Sign -> Type where | |
Z :: Whole either | |
S :: Whole 'Positive -> Whole 'Positive | |
P :: Whole 'Negative -> Whole 'Negative | |
type family Succ (x :: Whole sign) | |
:: Whole (SuccSign x) where | |
Succ 'Z = 'S 'Z | |
Succ ('S x) = 'S ('S x) | |
Succ ('P 'Z) = 'Z | |
Succ ('P x) = x | |
type family SuccSign (x :: Whole sign) :: Sign where | |
SuccSign 'Z = 'Positive | |
SuccSign ('S x) = 'Positive | |
SuccSign ('P 'Z) = forall k -> k -- ????? | |
SuccSign ('P x) = 'Negative |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment