[Haskell-cafe] DataKinds + KindSignatures question

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Nov 27 10:09:24 UTC 2014


On 27 November 2014 at 21:04, Wojtek Narczyński <wojtek at power.com.pl> wrote:
> On 27.11.2014 10:06, Frank Staals wrote:
>>
>>
>> As Karl explained, type parameters of (->) need to have kind *, whereas
>> your argument cmd has kind CmdKind.
>
>
> Okay, I get it now. I can't have regular functions on types of kind other
> than '*'. I must stop thinking of '*' as some of wildcard.
>
>> A ``workaround'' to this is using
>> Proxy (or any other type that has something of kind CmdKind as (phantom)
>> type). You can then define something like:
>>
>> import Data.Proxy
>>
>> class Serialize (cmd :: CmdKind) where
>>      serialize :: Proxy cmd -> ByteString
>>
>> myByteString = serialize (Proxy :: Proxy GET)
>>
>> Depending on what you are trying to do that may be applicable.
>>
>>
> Oh, so Proxy can be understood as a type level function from 'CmdKind' to
> '*'?

Not really: "Proxy CmdKind" is the safer/saner equivalent of doing
"(undefined :: CmdKind)" to be able to specify a type.

e.g.: show . (`asProxyTypeOf` (Proxy :: Proxy Int)) . read

It just brings the type into scope, not any actual values.

>
> --
> Kind regards,
> Wojtek Narczynski
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list