Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE ScopedTypeVariables #-}
- {-# LANGUAGE KindSignatures #-}
- {-# LANGUAGE FlexibleInstances #-}
- {-# LANGUAGE GADTs #-}
- module Main where
- main :: IO ()
- main = pure ()
- data Key a where
- KeyInt :: Key Int
- instance Show (Key a) where
- show KeyInt = "KeyInt"
- class KnownKey a where
- knownKey :: Maybe (Key a)
- knownKey = Nothing
- instance {-# INCOHERENT #-} KnownKey Int where
- knownKey = Just KeyInt
- instance {-# OVERLAPPING #-} KnownKey a where
- knownKey = Nothing
- myFunc :: forall a. a -> Maybe (Key a)
- myFunc val = (knownKey :: Maybe (Key a))
- -- hopefully
- -- >>> myFunc (3 :: Int) = Just KeyInt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement