Singular Type Constructor
Ashley Yakeley
ashley@semantic.org
Mon, 30 Jul 2001 19:08:50 -0700
Consider:
--
data T a = T
--
Is there anything in the Prelude or a standard library that looks like
this? Should there be? What should it be called? 'Singleton'? 'Reified'?
'T'?
I looked but couldn't find anything. Such a simple type constructor is in
fact very useful when you need to pass types around to disambiguate class
instances. For instance:
--
class HasTypeName t where
getTypeName :: T t -> String
instance HasTypeName Int where
getTypeName T = "Int"
instance HasTypeName () where
getTypeName T = "()"
intName = getTypeName (T :: T Int)
--
--
Ashley Yakeley, Seattle WA