<p><code>String</code> is a type all by itself so that a type <code>String String</code> does not actually make sense.</p>
<p>However, you can return a tuple of values so that your function would be:</p>
<pre><code>myAttempt :: Int -&gt; (String, String)
myAttempt _a = (&quot;Make this&quot;, &quot;Make that&quot;)
</code></pre>
<p>I added the underscore to <code>_a</code> so that the compiler will not give an &quot;unused parameter&quot; warning.</p>

CC BY-SA 4.0
2022-02-11T08:32:42.770Z
2022-02-11T08:32:42.770Z
Erik de Castro Lopo
<p>What about this example:</p>
<pre><code>f :: Integer -&gt; Maybe Integer
f x = if odd x then Nothing else Just x
</code></pre>
<p>Just like here you have <code>Maybe a</code> and you replace <code>a</code> with <code>Integer</code>, in your case you have the (rather complicated) type <code>Contract w s e a</code> where some of the type variables have been replaced with values.</p>
<p>You tried to do <code>String String</code> but <code>String</code> has no variables that you can replace with <code>String</code> - therefore the error about the appropriate kinds:</p>
<p><code>String :: *</code>, i.e. String is a type, while <code>Maybe :: * - *</code> i.e. you get a type by applying Maybe to a type.</p>

CC BY-SA 4.0
2022-02-11T11:43:20.440Z
2022-02-11T11:48:55.727Z
2022-02-11T11:48:55.727Z
Mihai Codescu
<p>I think you are misunderstanding the meaning of <code>Contract w FreeSchema Text ()</code>. This is one single <code>Contract</code> type. <code>w</code>, <code>FreeSchem</code>, <code>Text</code>, and <code>()</code> are like parametrisation of the type.</p>

CC BY-SA 4.0
2022-02-11T10:56:38.597Z
That makes sense. But I tried to create parallel syntax using more common data types and my own defined data types and I generate syntax errors. Is this because Contract is a Monad?
XiTouch
CC BY-SA 4.0
2022-02-11T08:37:16.710Z
2022-02-11T08:37:16.710Z
Jey
<p>I understand basic type signatures like</p>
<pre><code>myFunction :: Int -&gt; String
myFunction a = &quot;Always produce this string&quot;
</code></pre>
<p>But in the week 5 lesson, in Free.hs (and similar in the other hs files), I see this type signature (with implementation)</p>
<pre><code>mint :: MintParams -&gt; Contract w FreeSchema Text ()
mint mp = do
    let val     = Value.singleton curSymbol (mpTokenName mp) (mpAmount mp)
        lookups = Constraints.mintingPolicy policy
        tx      = Constraints.mustMintValue val
    ledgerTx &lt;- submitTxConstraintsWith @Void lookups tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    Contract.logInfo @String $ printf &quot;forged %s&quot; (show val)
</code></pre>
<p>It appears that the function produces multiple different outputs. I cannot reproduce this structure on my own using simple code such as</p>
<pre><code>myAttempt :: Int -&gt; String String
myAttempt a = &quot;Make this&quot; &quot;Make that&quot;
</code></pre>
<p>This causes the compiler to complain as follows</p>
<pre><code>*JWB2&gt; :l JWB2.hs
[1 of 1] Compiling JWB2             ( JWB2.hs, interpreted )

JWB2.hs:48:21: error:
    • Expected kind ‘* -&gt; *’, but ‘String’ has kind ‘*’
    • In the type signature: myAttempt :: Int -&gt; String String
   |
48 | myAttempt :: Int -&gt; String String
   |                     ^^^^^^^^^^^^^
Failed, no modules loaded.
</code></pre>
<p>Is this a capability added thru one of the LANGUAGE declarations? Or Plutus modules? A partial function? Unique to do blocks? Related to Monads?</p>
<p>Various searches have not provided an explanation, but I'm sure someone here can!</p>

<plutus-pioneer-program><haskell>
Please explain types with multiple outputs
# Please explain types with multiple outputs

(Asked by: username_0 on 2022-02-11)

I understand basic type signatures like
myFunction :: Int -> String
myFunction a = "Always produce this string"

But in the week 5 lesson, in Free.hs (and similar in the other hs files), I see this type signature (with implementation)
mint :: MintParams -> Contract w FreeSchema Text ()
mint mp = do
    let val     = Value.singleton curSymbol (mpTokenName mp) (mpAmount mp)
        lookups = Constraints.mintingPolicy policy
        tx      = Constraints.mustMintValue val
    ledgerTx <- submitTxConstraintsWith @Void lookups tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    Contract.logInfo @String $ printf "forged %s" (show val)

It appears that the function produces multiple different outputs. I cannot reproduce this structure on my own using simple code such as
myAttempt :: Int -> String String
myAttempt a = "Make this" "Make that"

This causes the compiler to complain as follows
*JWB2> :l JWB2.hs
[1 of 1] Compiling JWB2             ( JWB2.hs, interpreted )

JWB2.hs:48:21: error:
    • Expected kind ‘* -> *’, but ‘String’ has kind ‘*’
    • In the type signature: myAttempt :: Int -> String String
   |
48 | myAttempt :: Int -> String String
   |                     ^^^^^^^^^^^^^
Failed, no modules loaded.

Is this a capability added thru one of the LANGUAGE declarations? Or Plutus modules? A partial function? Unique to do blocks? Related to Monads?
Various searches have not provided an explanation, but I'm sure someone here can!

**Tags:** plutus-pioneer-program, haskell

---

## 3 answers

### Answer by username_1 on 2022-02-11. Score: 2

String is a type all by itself so that a type String String does not actually make sense.
However, you can return a tuple of values so that your function would be:
myAttempt :: Int -> (String, String)
myAttempt _a = ("Make this", "Make that")

I added the underscore to _a so that the compiler will not give an "unused parameter" warning.


---

### Answer by username_2 on 2022-02-11. Score: 2

What about this example:
f :: Integer -> Maybe Integer
f x = if odd x then Nothing else Just x

Just like here you have Maybe a and you replace a with Integer, in your case you have the (rather complicated) type Contract w s e a where some of the type variables have been replaced with values.
You tried to do String String but String has no variables that you can replace with String - therefore the error about the appropriate kinds:
String :: *, i.e. String is a type, while Maybe :: * - * i.e. you get a type by applying Maybe to a type.


---

### Answer by username_3 on 2022-02-11. Score: 2

I think you are misunderstanding the meaning of `Contract w FreeSchema Text ()`. This is one single `Contract` type. `w`, `FreeSchem`, `Text`, and `()` are like parametrisation of the type.

> **Comments:**
> **username_0**: That makes sense. But I tried to create parallel syntax using more common data types and my own defined data types and I generate syntax errors. Is this because Contract is a Monad?  

---

