Last active
November 13, 2016 02:14
-
-
Save mietek/763d5c3b4fc224aef19bdd06b84864fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 OverloadedStrings #-} | |
{-# LANGUAGE Rank2Types #-} | |
import Data.String (IsString, fromString) | |
import GHC.TypeLits (KnownSymbol, Symbol, someSymbolVal, symbolVal) | |
-- Singletons for built-in symbols. | |
data SingSymbol :: Symbol -> * where | |
SS :: forall s. KnownSymbol s => SingSymbol s | |
unsingSymbol :: forall s. SingSymbol s -> String | |
unsingSymbol ss@SS = symbolVal ss | |
data SomeSingSymbol :: * where | |
SSS :: forall s. SingSymbol s -> SomeSingSymbol | |
singSymbol :: String -> SomeSingSymbol | |
singSymbol s = SSS SS | |
{- | |
Sym1.hs:23:20: error: | |
• No instance for (KnownSymbol s0) arising from a use of ‘SS’ | |
• In the first argument of ‘SSS’, namely ‘SS’ | |
In the expression: SSS SS | |
In an equation for ‘singSymbol’: singSymbol s = SSS SS | |
Failed, modules loaded: none. | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment