kowainik / containers-backpack Goto Github PK
View Code? Open in Web Editor NEW๐ Backpack interface for containers
Home Page: https://kowainik.github.io/projects/containers-backpack
License: Mozilla Public License 2.0
๐ Backpack interface for containers
Home Page: https://kowainik.github.io/projects/containers-backpack
License: Mozilla Public License 2.0
Same as #41 but for insert/delete/etc.
functions
Basically, rewrite benchmarks from this module and them to map-contrib
package:
It's okay to have Map.Group.Bench.Lookup
module and depend on gauge
library in map-contrib
. We're in prototyping stage now, so it's completely okay to have non-optmized dependencies.
unpacked-containers
is itself implemented with the help of Backpack! So it's rather exciting to have Map.hsig
instance for this package as well.
Some functions are reexported directly from the corresponding libraries. But most of them are implemented in our signatures. To improve performance, it's better to add {-# INLINE #-}
pragma to every function.
So, for example, if we have:
singleton :: Key k => k -> v -> Map k v
singleton = HM.singleton
This should be written like this:
singleton :: Key k => k -> v -> Map k v
singleton = HM.singleton
{-# INLINE singleton #-}
And we should do this for every function in every instance.
Probably this issue is not urgent, let's figure out proper interface for Map
s first.
There's this useful operator:
infixl 9 !?
(!?) :: Key k => Map k v -> k -> Maybe v
(!?) m k = lookup k m
And probably there exist other useful functions with default implementations. We need to collect such functions and put them near signatures. Though, good naming for module is most difficult part here...
Change library
to executable and print result to terminal. After something meaningful is implemented in contrib
Probably in separate package like containers-sig-laws
.
Some tests introduced in #34 are unit tests and some are property-based tests. It would be really nice to somehow separate tests. For example, this one is unit test:
But this looks like property-based test:
I would love to have 3 test-suites:
My proposal is to use hspec
for unit tests. QuickCheck can be used now for property-based tests.
Basically, reimplement this module:
The following generator looks strange. Probably Gen
is not needed there (or I'm not sure)
And update the blog post accordingly.
Currently packages have the following name:
map-sig
: singatures for readonly mapsmap-sig-extended
: signatures for modifiable mapsmap-containers-map
: implementation of map-sig
for Map.Lazy
from containers
packagemap-containers-intmap
: implementation of map-sig
for IntMap.Lazy
from containers
packagemap-unordered
: implementation of map-sig
for HashMap.Strict
from unordered-containers
map-primitive
: implementaiton of map-sig
for pritimitive-containers
map-contrib
: different functions implemented using only map-sig
packagemap-
prefix is not good because map-sig
package also can have signatures for Set
without any problems.
Any better suggestions?
See map-containers
for example
Currently suites take Proxy
as an argument. But it's better to use AllowAmbiguousTypes
extension to not pass Proxy
and pass types directly.
This means even more boilerplate code... We need to add the following:
Map.Lazy
HashMap.Lazy
IntMap.Lazy
Need to open issue to primitive-containers
package.
It's better for performance reasons. But not obvious, how to achieve this...
These functions can be put directly to containers-sig-*
packages.
!?
as an operator version of lookup
//
for Map differenceFor example, there's this useful operator:
infixl 9 !?
(!?) :: Key k => Map k v -> k -> Maybe v
(!?) m k = lookup k m
And probably there exist other useful functions with default implementations. We need to collect such functions and put them near signatures. Though, good naming for module is most difficult part here...
Hi,
I believe I found the relevant docs for how to do this. However, I'm still running into trouble. My commit shows the relevant changes to the stack/cabal files, but note that some of the code changes are nonsense. However, it appears to fail before the code changes would cause a compilation failure:
stack build
Progress 0/5 containers-sig-readonly-0.0.0: configure (lib)
Progress 0/5 containers-sig-0.0.0: configure (lib)
Progress 0/5 containers-sig-readonly-0.0.0: build (lib)
Progress 0/5 containers-sig-readonly-0.0.0: copy/register
Progress 0/5 Progress 1/5: containers-ordered-strict-0.0.0, containers-sig-0.0.0 containers-ordered-strict-0.0.0: configure (lib)
Progress 1/5: containers-ordered-strict-0.0.0, containers-sig-0.0.0 containers-sig-0.0.0: build (lib)
Progress 1/5: containers-ordered-strict-0.0.0, containers-sig-0.0.0 containers-sig-0.0.0: copy/register
Progress 1/5: containers-ordered-strict-0.0.0, containers-sig-0.0.0 Progress 2/5: containers-contrib-0.0.0, containers-ordered-strict-0.0.0 containers-contrib-0.0.0: configure (lib)
Progress 2/5: containers-contrib-0.0.0, containers-ordered-strict-0.0.0 containers-ordered-strict-0.0.0: build (lib)
Progress 2/5: containers-contrib-0.0.0, containers-ordered-strict-0.0.0 containers-ordered-strict-0.0.0: copy/register
Progress 2/5: containers-contrib-0.0.0, containers-ordered-strict-0.0.0 containers-contrib-0.0.0: build (lib)
Progress 2/5: containers-contrib-0.0.0, containers-ordered-strict-0.0.0 Progress 3/5: containers-contrib-0.0.0 containers-contrib-0.0.0: copy/register
Progress 3/5: containers-contrib-0.0.0 hico-0.1.0.0: configure (lib + exe)
Progress 3/5: containers-contrib-0.0.0 Progress 4/5: hico-0.1.0.0 Configuring hico-0.1.0.0...
Progress 4/5: hico-0.1.0.0 Error:
Progress 4/5: hico-0.1.0.0 The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
Progress 4/5: hico-0.1.0.0 planned package hico-0.1.0.0 is broken due to missing package containers-contrib-0.0.0-CVCQxd4JzxzGeMuWdr5u0d+B3uxSMlrl2y2Er6UNvkdGh
Progress 4/5: hico-0.1.0.0
Progress 4/5: hico-0.1.0.0 Completed 5 action(s).
The tests are implemented in this module:
Probably some tests are missing there. I propose to think more about all possible tests, document them in some mathy or unicode way and then add more tests if necessary.
Like on this slide:
Like in this module:
The problem appeared in pull request by @yigitozkavci (#43). The fact that Map
from primitive-containers
doesn't have NFData
instance doesn't allow to benchmark this data type...
And write some function that uses only read-only operations.
This module:
Basically, do similar things that were done in this PR:
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.