File: Bool.hs

package info (click to toggle)
bali-phy 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,392 kB
  • sloc: cpp: 120,442; xml: 13,966; haskell: 9,975; python: 2,936; yacc: 1,328; perl: 1,169; lex: 912; sh: 343; makefile: 26
file content (33 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}

module Data.Type.Bool where

data TrueType
data FalseType

type family If cond tru fls where
    If TrueType  tru fls = tru
    If FalseType tru fls = fls

type family AndType a b where
    AndType FalseType b         = FalseType
    AndType TrueType  b         = TrueType
    AndType a         FalseType = FalseType
    AndType a         TrueType  = TrueType
    AndType a         a         = a
-- infixr 2 &&

type family OrType a b where
  OrType FalseType a         = a
  OrType TrueType  a         = TrueType
  OrType a         FalseType = a
  OrType a         TrueType  = TrueType
  OrType a         a         = a
-- infixr 2 ||

type family Not a where -- Not a = res | res -> a
    Not FalseType = TrueType
    Not TrueType  = FalseType