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