Skip to content

Instantly share code, notes, and snippets.

@nicuveo
Created December 27, 2020 02:09
Show Gist options
  • Save nicuveo/275d66bcc179e586444ce3cee9871536 to your computer and use it in GitHub Desktop.
Save nicuveo/275d66bcc179e586444ce3cee9871536 to your computer and use it in GitHub Desktop.
{-# 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