jonathanknowles / monoidmap Goto Github PK
View Code? Open in Web Editor NEWMonoidal map type with support for semigroup and monoid subclasses.
Home Page: https://hackage.haskell.org/package/monoidmap
License: Apache License 2.0
Monoidal map type with support for semigroup and monoid subclasses.
Home Page: https://hackage.haskell.org/package/monoidmap
License: Apache License 2.0
The fromMap
operation is currently defined as:
fromMap :: MonoidNull v => Map k v -> MonoidMap k v
fromMap = MonoidMap . Map.mapMaybe maybeNonNull
Internally, this always creates a new Map
structure, even if the original Map
is already in canonical form (i.e., contains no mempty
values).
It might be desirable to first check whether the provided Map
is in canonical form, and if so, just perform a coercion, thus avoiding the creation of a new Map
structure:
fromMap :: MonoidNull v => Map k v -> MonoidMap k v
fromMap m
| not (any MonoidNull.null m) = coerce m
| otherwise = MonoidMap (Map.mapMaybe maybeNonNull m)
However, one downside of this optimisation is that it penalises the general case, which would now require two traversals of the original map, whereas before only one traversal was required.
We might be able to get the best of both worlds by providing two operations, and allowing the caller to choose:
fromMap :: MonoidNull v => Map k v -> MonoidMap k v
fromMap = MonoidMap . Map.mapMaybe maybeNonNull
fromMapNonNull :: MonoidNull v => Map k v -> MonoidMap k v
fromMapNonNull m
| not (any MonoidNull.null m) = coerce m
| otherwise = fromMap m
QuickCheck
version 2.15
has been released:
https://hackage.haskell.org/package/QuickCheck-2.15
However, this package has the following upper bound that prevents building with the new release:
QuickCheck < 2.15
Suggested solution: bump the upper bound to:
QuickCheck < 2.16
Related issue: commercialhaskell/stackage#7391
Related upstream tickets:
commutative-semigroups
quickcheck-monoid-subclasses
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.