Created
September 16, 2015 10:35
-
-
Save NicolasT/7ad255e9eca94be21315 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 DataKinds #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
module Langs where | |
import Data.Proxy | |
import GHC.TypeLits | |
data Language (code :: Symbol) where | |
English :: Language "en" | |
Dutch :: Language "nl" | |
French :: Language "fr" | |
deriving instance Show (Language code) | |
doSomething :: forall code. KnownSymbol code => Language code -> String | |
doSomething lang = "The code for " ++ show lang ++ " is " ++ show code | |
where | |
code = symbolVal (Proxy :: Proxy code) | |
main :: IO () | |
main = do | |
putStrLn $ doSomething Dutch | |
putStrLn $ doSomething English |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hot, I'm adding this