Created
February 15, 2018 18:29
-
-
Save chessai/430b803f141b7ab22b2aebee72b495e2 to your computer and use it in GitHub Desktop.
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 DataKinds #-} | |
| {-# LANGUAGE NoImplicitPrelude #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| module Data.Type.Ord | |
| ( Compare | |
| , OrdCase | |
| , IsEQ | |
| , IsLT | |
| , IsGT | |
| ) | |
| import Data.Bool (Bool(..)) | |
| import Data.Ord (Ordering(..)) | |
| type family Compare (l :: k) (r :: k) :: Ordering | |
| type family OrdCase (x :: Ordering) (a :: k) (b :: k) (c :: k) :: k where | |
| OrdCase LT a b c = a | |
| OrdCase EQ a b c = b | |
| OrdCase GT a b c = c | |
| type IsLT t = OrdCase t True False False | |
| type IsEQ t = OrdCase t False True False | |
| type IsGT t = OrdCase t False False True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment