Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Kind (Type)
import Data.Type.Bool
type family Contains (a :: Type) (b :: k) :: Bool where
Contains a a = 'True
Contains a (f x) = Contains a f || Contains a x
Contains _ _ = 'False
class ToBool (b :: Bool) where
toBool :: Bool
instance ToBool 'True where toBool = True
instance ToBool 'False where toBool = False
main :: IO ()
main = do
print $ toBool @(Contains Int (Either (Maybe [IO Int]) String)
print $ toBool @(Contains [IO Int] (Either (Maybe [IO Int]) String)
print $ toBool @(Contains (Maybe Int) (Either (Maybe [IO Int]) String)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment