IntersectMBO / ouroboros-network

Specifications of network protocols and implementations of components running these protocols which support a family of Ouroboros Consesus protocols; the diffusion layer of the Cardano Node.

Home Page:https://ouroboros-network.cardano.intersectmbo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `foldMap1'` in `O.N.Protocol.Handshake.Version.foldMapVersions`

samcowger opened this issue · comments

At the moment, foldMapVersions is rendered like so:

https://github.com/input-output-hk/ouroboros-network/blob/cdd54f98c6743f5fd7bfe0d5a9d0b0f8a4a10b73/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake/Version.hs#L62-L74

foldMapVersions is precisely foldMap1, and could be more efficiently rendered as foldMap1'. These functions are included in Foldable1, a class introduced in base-4.18, so once ouroboros-network-frameworks is migrated to GHC 9.6, we should leverage one of them (probably foldMap1') in this definition. (The current definition's inefficiency comes from converting to a list and using a lazy left fold., foldl1.)