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.

1 Answer 1


This code is implementing the ValidatorTypes "Typeclass" 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 is the definition of that typeclass.

Check out the "Typeclasses 102" section in the Learn You A Haskell tutorial (scroll down) to learn more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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