Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Data.Map with Data.Map.Strict #4675

Merged
merged 2 commits into from
Dec 7, 2022
Merged

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Nov 28, 2022

Resolves #4648

import Data.Map (Map)
import qualified Data.Map as Map
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import qualified Data.Map.Strict as SMap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are importing Data.Map.Strict twice here. Also wondering if we should import as SMap to prevent confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually just suggest replacing all uses of SMap with Map.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So LMap if we ever need to reach for a lazy map?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it ever comes up, personally, I'd suggest importing Data.Map.Lazy as Lazy unless that clashes with something, because it reads rather nicely.
The underlying datatype is shared between Data.Map.Lazy and Data.Map.Strict, so simply using Data.Map.Strict isn't a magic bullet, since something innocuous like fmap won't keep your values in WHNF and you can easily be given "lazy" maps where the values aren't already in WHNF. Honestly, I think it'd be better off as a newtype if you "really" want strictness, but that's probably be a discussion for another time.

Copy link
Contributor

@erikd erikd Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Lazy is too generic (both Text and ByetString have lazy versions. I also think LMap is not as good a name as LazyMap.

Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm changing it to Map in this PR as it's concerned with the removal of Data.Map. However John and Robert can have the ultimate decision (whilst considering Erik's input) and open a new PR with the relevant changes. This PR should also update the style doc so we can compile a list of how modules should be imported so it's not ambiguous.

@Jimbo4350
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Nov 29, 2022
4675: Replace Data.Map with Data.Map.Strict r=Jimbo4350 a=Jimbo4350

Resolves #4648 

Co-authored-by: Jordan Millar <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 29, 2022

Build failed:

@Jimbo4350 Jimbo4350 merged commit fe5508a into master Dec 7, 2022
@iohk-bors iohk-bors bot deleted the jordan/remove-data-map-usage branch December 7, 2022 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] - Replace all uses of Data.Map with the strict version
4 participants