{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
import Data.Proxy | |
import Data.Typeable | |
contains :: forall a b. (Typeable a, Typeable b) => Bool | |
contains = go typeB | |
where typeA = typeRep (Proxy :: Proxy a) | |
typeB = typeRep (Proxy :: Proxy b) | |
go x = x == typeA || any go (typeRepArgs x) | |
main :: IO () | |
main = do | |
print $ contains @Int @(Either (Maybe [IO Int]) String) | |
print $ contains @[IO Int] @(Either (Maybe [IO Int]) String) | |
print $ 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