<p>This code is implementing the <code>ValidatorTypes</code> <a href="https://en.wikipedia.org/wiki/Type_class" rel="nofollow noreferrer">&quot;Typeclass&quot;</a> for the <code>Auctioning</code> datatype.</p>
<p>Typeclasses are Haskell's way of handling polymorphism, like abstract classes in an OO language. In this case, the <code>ValidatorTypes</code> typeclass has two associated types, <code>RedeemerType</code> and <code>DatumType</code>, that need to be defined for our validator. <a href="https://github.com/input-output-hk/plutus/blob/master/plutus-ledger/src/Ledger/Typed/Scripts/Validators.hs#L45" rel="nofollow noreferrer">Here</a> is the definition of that typeclass.</p>
<p>Check out the &quot;Typeclasses 102&quot; section in the <a href="http://learnyouahaskell.com/making-our-own-types-and-typeclasses" rel="nofollow noreferrer">Learn You A Haskell</a> tutorial (scroll down) to learn more.</p>

CC BY-SA 4.0
2021-08-17T07:33:49.687Z
2021-08-17T07:33:49.687Z
Mitchell Turner
<p>I have already learned haskell from <a href="http://learnyouahaskell.com/chapters" rel="noreferrer">http://learnyouahaskell.com/chapters</a>, but it doesn't cover the type instance syntax, like this:</p>
<pre><code>data Auctioning
instance Scripts.ValidatorTypes Auctioning where
    type instance RedeemerType Auctioning = AuctionAction
    type instance DatumType Auctioning = AuctionDatum
 
</code></pre>
<p>I known the first line is declared the Auctioning date type, the second line is make Auctioning instance of ValidatorTypes, but what does type instance means? I can't find this syntax from haskell.</p>

<plutus><plutus-pioneer-program><haskell>
Type instance syntax
# Type instance syntax

(Asked by: username_0 on 2021-08-17)

I have already learned haskell from http://learnyouahaskell.com/chapters, but it doesn't cover the type instance syntax, like this:
data Auctioning
instance Scripts.ValidatorTypes Auctioning where
    type instance RedeemerType Auctioning = AuctionAction
    type instance DatumType Auctioning = AuctionDatum
 

I known the first line is declared the Auctioning date type, the second line is make Auctioning instance of ValidatorTypes, but what does type instance means? I can't find this syntax from haskell.

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

---

## 1 answers

### Answer by username_1 on 2021-08-17. Score: 3

This code is implementing the `ValidatorTypes` ["Typeclass"](https://en.wikipedia.org/wiki/Type_class) for the `Auctioning` datatype.

Typeclasses are Haskell's way of handling polymorphism, like abstract classes in an OO language. In this case, the `ValidatorTypes` typeclass has two associated types, `RedeemerType` and `DatumType`, that need to be defined for our validator. [Here](https://github.com/input-output-hk/plutus/blob/master/plutus-ledger/src/Ledger/Typed/Scripts/Validators.hs#L45) is the definition of that typeclass.

Check out the "Typeclasses 102" section in the [Learn You A Haskell](http://learnyouahaskell.com/making-our-own-types-and-typeclasses) tutorial (scroll down) to learn more.


---

