Created
August 18, 2017 14:17
-
-
Save LukaHorvat/8e9a1af8ce2ca0b09c6902208650a6b6 to your computer and use it in GitHub Desktop.
Without
This file contains 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
type family Elem (x :: k) (xs :: [k]) :: Bool where | |
Elem x '[] = 'False | |
Elem x (x ': xs) = 'True | |
Elem x (y ': xs) = Elem x xs | |
type family If (condition :: Bool) (t :: k) (e :: k) :: k where | |
If 'True t e = t | |
If 'False t e = e | |
type family Without (xs :: [k]) (ys :: [k]) :: [k] where | |
Without xs '[] = xs | |
Without '[] ys = '[] | |
Without (x ': xs) ys = If (x `Elem` ys) (Without xs ys) (x ': Without xs ys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment