1

According type applications, this extension allows to give explicit type arguments to a polymorphic function.

type VestingSchema =
             Endpoint "give" GiveParams
         .\/ Endpoint "grab" ()
-- ...
endpoints :: Contract () VestingSchema Text ()
endpoints = awaitPromise (give' `select` grab') >> endpoints
   where
     give' = endpoint @"give" give
     grab' = endpoint @"grab" $ const grab

This does not allows to give values to a polymorphic function, so I have figured out that actually those "strings" at @"give" and @"grab" are actually something similar to types, because the type Endpoint has this type/kind signature:

type Endpoint :: ghc-prim-0.6.1:GHC.Types.Symbol
                 -> * -> row-types-1.0.1.2:Data.Row.Internal.Row *
type Endpoint l a =
  l
  row-types-1.0.1.2:Data.Row.Internal..== (Wallet.Types.EndpointValue
                                             a,
                                           Plutus.Contract.Effects.ActiveEndpoint)
  :: row-types-1.0.1.2:Data.Row.Internal.Row *
        -- Defined in ‘Plutus.Contract.Request

So that l has kind Symbol. Why this is working with TypeApplications? Can I use this "give" and "grab" as type and/or type constructors anywhere in my code?

1 Answer 1

0

The extension that you are after is not TypeAplications, but DataKinds. I liked the explanations here: https://stackoverflow.com/questions/20558648/what-is-the-datakinds-extension-of-haskell

3
  • DataKinds explains why Endpoint can receive a type as argument and return a concret type, but it does not explain why I am allowed to use "give" and "grab" as type references on @ operator argument Feb 21, 2022 at 18:44
  • No, because of DataKinds you can use "give" as a type, both in Endpoint and in the type application. Because of the DataKindsextension, String becomes a kind and the values of type String become types of kind String. Feb 21, 2022 at 19:12
  • 1
    Also see the example Lars gave in the lecture youtu.be/…: 1. type application allows us to disambiguate the type of callEndpoint 2. data kinds allows us to use type-level strings Feb 21, 2022 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.