Skip to content

Instantly share code, notes, and snippets.

@i-am-tom
Created March 2, 2019 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i-am-tom/462b10a67dde895f6ce2b982553ee56a to your computer and use it in GitHub Desktop.
Save i-am-tom/462b10a67dde895f6ce2b982553ee56a to your computer and use it in GitHub Desktop.
Visible quantification???
{-# 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