IntersectMBO / IntersectMBO/ouroboros-network

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

Open
#4,677 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
296
Forks
104
Avg merge
2d 10h
Merged PRs (30d)
4

Description

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`](https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-Foldable1.html), 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`.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.