Skip to content

Instantly share code, notes, and snippets.

@Shimuuar
Created August 17, 2014 13:27
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 Shimuuar/d45bcecbd4ead77ee34a to your computer and use it in GitHub Desktop.
Save Shimuuar/d45bcecbd4ead77ee34a to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
module TySet where
type InsertRes x set = If (Member x set) set (x ': set)
type family If f a b where
If True a b = a
If False a b = b
type family Member (x :: α) (set :: [α]) :: Bool where
Member x '[] = False
Member x (x ': xs) = True
Member x (y ': xs) = Member x xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment