Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE FlexibleContexts, KindSignatures, TypeFamilies #-}
- import Data.Proxy
- class IsFun a where
- isFunProxy :: (Proxy a) -> Bool
- data Fun
- data NotFun
- instance IsFun Fun where
- isFunProxy _ = True
- instance IsFun NotFun where
- isFunProxy _ = False
- type family IsFun' (a :: *) where
- IsFun' (a -> b) = Fun
- IsFun' a = NotFun
- proxy :: a -> Proxy (IsFun' a)
- proxy _ = Proxy
- isFun :: (IsFun (IsFun' a)) => a -> Bool
- isFun a = isFunProxy $ proxy a
- f1 :: Int -> Int
- f1 = id
- f2 :: Int -> Int -> Int
- f2 = const
- v :: Int
- v = 0
- main = do
- print $ isFun f1
- print $ isFun f2
- print $ isFun v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement