Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2020 02:09
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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