I would like to be able to explicitly apply an argument of kind other than Type
to a dummy constructor purely for documentation purposes. However TypeApplications
does not seem to support this scenario:
{-# LANGUAGE GADTs, PolyKinds, ScopedTypeVariables, TypeApplications #-}
data EQ :: k -> k -> * where
Refl :: EQ a a
data Wrap (a :: k) = Wrap (EQ a a)
wrap :: forall (a :: k). Wrap a
wrap = Wrap @a Refl
leads to the error
ProxyApply.hs:9:14: error:
• Expected a type, but ‘a’ has kind ‘k’
• In the type ‘a’
In the expression: Wrap @a Refl
In an equation for ‘wrap’: wrap = Wrap @a Refl
• Relevant bindings include
wrap :: Wrap a (bound at ProxyApply.hs:9:1)
Is there a way to do this?
Arguments of Persuasion —used to change someone’s thinking on a topic or person. Arguments of Evaluation —critical reviews based on logical evaluation of criteria and evidence for that evaluation. Arguments of Fact and Explanation —establishes that a fact is true (the former) or why it is true (the latter).
Sometimes instructors will give you free rein on choosing your own topic, and sometimes they will assign one to you. Depending on the class theme, the type of text you interact with, and the professor, there are a variety of ways to write an argument.
Proposal Arguments In this type of argument, you must propose a solution to a problem. First, you must establish a clear problem and then propose a specific solution to that problem. For example, you might argue for a proposal that would increase retention rates at your college.
The type arguments are written within angle brackets ( < and >) immediately following the name of the generic type. A type that includes at least one type argument is called a constructed type. A constructed type can be used in most places in the language in which a type name can appear.
I think you’ve found a type checker bug.
The way kind variables are implemented, GHC passes around an extra type parameter behind the scenes. This type parameter is supposed to be implicit and filled in by unification, but sometimes it shows up. (That's why you sometimes see extra type parameters in Haddocks, eg in Proxy
's instance list.)
This appears to be one of those situations: the type checker thinks you’re passing the k
parameter. Luckily it seems like you can work around it by passing the kind variable explicitly.
wrap :: forall (a :: k). Wrap a
wrap = Wrap @k @a Refl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With