mikolaj / enummapset Goto Github PK
View Code? Open in Web Editor NEWIntMap and IntSet with Enum keys/elements.
License: BSD 3-Clause "New" or "Revised" License
IntMap and IntSet with Enum keys/elements.
License: BSD 3-Clause "New" or "Revised" License
It's even faster than just checking if intersection is empty.
Building enummapset-0.5.2.2
Failed to install enummapset-0.5.2.2
Build log ( ~/.cabal/logs/ghc-8.6.0.20180823/enummapset-0.5.2.2-2u0xauM3JVBCyceeGTpYwG.log ):
cabal: Entering directory '/tmp/cabal-tmp-26260/enummapset-0.5.2.2'
Configuring enummapset-0.5.2.2...
Preprocessing library for enummapset-0.5.2.2..
Building library for enummapset-0.5.2.2..
[1 of 5] Compiling Data.EnumSet ( Data/EnumSet.hs, dist/build/Data/EnumSet.o )
[2 of 5] Compiling Data.EnumMap.Base ( Data/EnumMap/Base.hs, dist/build/Data/EnumMap/Base.o )
[3 of 5] Compiling Data.EnumMap.Strict ( Data/EnumMap/Strict.hs, dist/build/Data/EnumMap/Strict.o )
[4 of 5] Compiling Data.EnumMap.Lazy ( Data/EnumMap/Lazy.hs, dist/build/Data/EnumMap/Lazy.o )
[5 of 5] Compiling Data.EnumMap ( Data/EnumMap.hs, dist/build/Data/EnumMap.o )
Data/EnumMap.hs:30:31: error:
• Data.IntMap.insertWith' is gone. Use Data.IntMap.Strict.insertWith.
• In the first argument of ‘(.)’, namely
‘I.insertWith' f (fromEnum k) x’
In the second argument of ‘(.)’, namely
‘I.insertWith' f (fromEnum k) x . unWrap’
In the expression:
EnumMap . I.insertWith' f (fromEnum k) x . unWrap
|
30 | insertWith' f k x = EnumMap . I.insertWith' f (fromEnum k) x . unWrap
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Data/EnumMap.hs:35:13: error:
• Data.IntMap.insertWithKey' is gone. Use Data.IntMap.Strict.insertWithKey.
• In the first argument of ‘(.)’, namely
‘I.insertWithKey' (f . toEnum) (fromEnum k) x’
In the second argument of ‘(.)’, namely
‘I.insertWithKey' (f . toEnum) (fromEnum k) x . unWrap’
In the expression:
EnumMap . I.insertWithKey' (f . toEnum) (fromEnum k) x . unWrap
|
35 | EnumMap . I.insertWithKey' (f . toEnum) (fromEnum k) x . unWrap
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Data/EnumMap.hs:38:12: error:
• Data.IntMap.fold' is gone. Use Data.IntMap.foldr or Prelude.foldr.
• In the first argument of ‘(.)’, namely ‘I.fold f a’
In the expression: I.fold f a . unWrap
In an equation for ‘fold’: fold f a = I.fold f a . unWrap
|
38 | fold f a = I.fold f a . unWrap
| ^^^^^^^^^^
Data/EnumMap.hs:41:19: error:
• Data.IntMap.foldWithKey is gone. Use foldrWithKey.
• In the first argument of ‘(.)’, namely
‘I.foldWithKey (f . toEnum) a’
In the expression: I.foldWithKey (f . toEnum) a . unWrap
In an equation for ‘foldWithKey’:
foldWithKey f a = I.foldWithKey (f . toEnum) a . unWrap
|
41 | foldWithKey f a = I.foldWithKey (f . toEnum) a . unWrap
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Leaving directory '/tmp/cabal-tmp-26260/enummapset-0.5.2.2'
EnumSet
and EnumMap
should provide at least the same instances as IntSet
and IntMap
respectively
The patch is here: https://gitlab.haskell.org/ghc/head.hackage/-/blob/master/patches/enummapset-0.7.1.0.patch?ref_type=heads
@TeofilC, is this supposed to be a clean fix or a quick-fix that only works for GHC 9.12 and newer?
[2 of 5] Compiling Data.EnumMap.Base ( Data/EnumMap/Base.hs, dist/dist-sandbox-62e6f0ad/build/Data/EnumMap/Base.o )
Data/EnumMap/Base.hs:180:49:
Can't make a derived instance of ‘Traversable (EnumMap k)’
(even with cunning newtype deriving):
You need DeriveTraversable to derive an instance for this class
In the newtype declaration for ‘EnumMap’
cabal: Error: some packages failed to install:
enummapset-0.5.2.0 failed during the building phase. The exception was:
ExitFailure 1
I have found the above to be extremely useful for generically working with various types of Maps. Between them you basically get filtering, unioning and intersecting in a convenient and generic way.
I realize this means depending on witherable
, these
and semigroupoids
. But alas the current Haskell orphan instances situation means that there isn't really a good way around that.
Add semigroup instances.
See also: https://ghc.haskell.org/trac/ghc/wiki/Migration/8.4#SemigroupMonoidsuperclasses
Building library for enummapset-0.5.2.1..
[1 of 5] Compiling Data.EnumSet ( Data/EnumSet.hs, dist/build/Data/EnumSet.o )
Data/EnumSet.hs:111:17: error:
• No instance for (Semigroup (EnumSet k))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (Monoid (EnumSet k))
|
111 | deriving (Eq, Monoid, Ord, Typeable, NFData)
| ^^^^^^
In particular, the restriction on base prevents building on GHC 7.2.1.
The name (EnumMap) seems wrong, though. The module will
be imported qualified anyways, so the type should just be Map.
Then, changing the implementation (if the key type implements
Ord, Enum, and Hashable) is really just changing the import.
But then, it's at least consistently wrong -
e.g., in line with Data.HashMap.
see also discussion in this thread: https://mail.haskell.org/pipermail/haskell-cafe/2015-March/118897.html
The Show instances show the same output as IntMap and IntSet do. Mapping toEnum over the resulting lists would enable compiling the shown value in ghci without the need to fix it manually. I suppose this requires an analogous change in Read.
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.