Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/{-# LANGUAGE DeriveFoldable #-} automatic typeclass derivationForum ↗

{-# LANGUAGE DeriveFoldable #-} automatic typeclass derivation

App Development2 posts453 views4 likesLast activity Mar 2021
LU
LucianoOP
Mar 2021

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

There is no documented list atm but the source code isn’t too hard to understand

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?

CO
cocreature
Mar 2021

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.

← Back to Discussions