Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/No Foldable instance for SetForum ↗

No Foldable instance for Set

App Development4 posts641 views14 likesLast activity Jun 2021
HU
huwOP
Jun 2021 5

It seems there is no Foldable instance for Set. It would be useful to have an instance. Also Haskell does have a Foldable instance for its set type. Or is there some technical reason that it can’t have an instance?

BE
bernhard
Jun 2021 2

I don’t think there’s a technical reason. You can very easily add your own instance:

import DA.Set as S
import DA.Foldable as F

instance Foldable Set where
  foldr fn b xs = F.foldr fn b (S.toList xs)
CO
cocreature
Jun 2021 6

Thanks for the suggestion! We just added this Add a Foldable instance for Set by cocreature · Pull Request #9860 · digital-asset/daml · GitHub and it will be included in tomorrow’s snapshot and the 1.14 release.

HU
huw
Jun 2021 1

Thanks guys. Not hard to add my own but then it would be an orphan instance (at least in the Haskell world, I guess DAML has the same notion of orphan instances).

← Back to Discussions