{-# LANGUAGE DeriveFoldable #-} automatic typeclass derivation

Continuing the discussion from Which subset of Haskell is available?:

Following the link I see that no Derivexxx language extensions are enabled. e.g. DeriveFoldable. But when I write deriving Foldable in Daml, I see in the error message:

  daml/ContingentClaims/Claim.daml:138:22: error:
  • Can't make a derived instance of ‘Foldable (ClaimF f t a)’:
  ‘Foldable’ is not a stock derivable class (Eq, Show, etc.)
  Try enabling DeriveAnyClass
  • In the data declaration for ‘ClaimF’

Is the “Try enabling DeriveAnyClass” just a red herring? Or is there some way I can enable type class deriviation through an extension?

2 Likes

DeriveAnyClass is a red herring. It will simply create empty instances. This only works for typeclasses that have default methods everywhere.

Allowing DeriveFoldable doesn’t seem that unreasonable, I think it might just be an oversight that it’s not allowed atm.

2 Likes