Created
June 18, 2017 18:35
-
-
Save sdiehl/d033bfdbb02760b23e45ffeca7482957 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 ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
module Test where | |
import GHC.Generics | |
import Data.Proxy | |
typeName :: forall a. (Generic a, GTypeName (Rep a)) => Proxy a -> String | |
typeName Proxy = gtypename (from (undefined :: a)) | |
class GTypeName f where | |
gtypename :: f a -> String | |
instance (Datatype c) => GTypeName (M1 i c f) where | |
gtypename m = datatypeName m | |
unit :: String | |
unit = typeName (Proxy :: Proxy ()) | |
int :: String | |
int = typeName (Proxy :: Proxy Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment