Created
December 4, 2017 03:22
-
-
Save adituv/a06540031ce024a763af5825bafa1942 to your computer and use it in GitHub Desktop.
No proxies thanks to -XTypeApplications!
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 FlexibleContexts #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
data Nat = Z | S Nat | |
class Demote (a :: k) base | a -> base where | |
demote :: base | |
instance Demote 'Z Integer where | |
demote = 0 | |
instance forall n. Demote n Integer => Demote ('S n) Integer where | |
demote = 1 + demote @n | |
type Four = S (S (S (S Z))) | |
main :: IO () | |
main = print $ demote @Four |
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 TypeApplications #-} | |
class ShowType a where | |
showType :: String | |
instance ShowType Int where | |
showType = "Int" | |
instance ShowType Bool where | |
showType = "Bool" | |
main :: IO () | |
main = do | |
putStrLn $ showType @Int | |
putStrLn $ showType @Bool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment