
11 Mar
2014
11 Mar
'14
9:34 p.m.
Dear Niklas, On Wed, Mar 12, 2014 at 01:10:19AM +0100, Niklas Haas wrote:
Oops, sorry, that was supposed to have been:
dataTypeOf :: Data a => Proxy a -> DataType or dataTypeOf :: Data a => p a -> DataType
As for the implementation, the simplest possible (ie. no language extensions) implementation I can think of looks like this:
dataTypeOf = Data.dataTypeOf . f where f :: p a -> a f _ = error "dataTypeOf: this should never be used"
where Data.dataTypeOf refers to the ‘original’ version of that function.
Awesomeness! I see now what you meant by Proxy and that Data.dataTypeOf doesn't even get evaluated, i.e. its sole purpose is to ferry the type information across… Neat. Much obliged, S. -- Семен Тригубенко http://trygub.com