pruvisto / heap Goto Github PK
View Code? Open in Web Editor NEWA flexible Haskell implementation of minimum, maximum, minimum-priority, maximum-priority and custom-ordered heaps.
License: BSD 2-Clause "Simplified" License
A flexible Haskell implementation of minimum, maximum, minimum-priority, maximum-priority and custom-ordered heaps.
License: BSD 2-Clause "Simplified" License
extractHeap in heap-1.0.* has been deprecated in favor of view but is required in MidiIO.hs.
First off, thanks for your work on this library! It's been a big help for my work.
When building this from Hackage, the library automatically pulls in QuickCheck as a dependency, even though QuickCheck isn't actually part of the package's interface. I think this can be fixed by changing the test target from an "Executable" to a "Test-Suite" (example).
Configuring component lib from heap-1.0.3...
Preprocessing library heap-1.0.3...
[1 of 3] Compiling Data.Heap.Internal ( Data/Heap/Internal.hs, /tmp/matrix-worker/1496496621/dist-newstyle/build/x86_64-linux/ghc-7.4.2/heap-1.0.3/build/Data/Heap/Internal.o )
Data/Heap/Internal.hs:36:54:
Module `Prelude' does not export `foldMap'
I've already revised the meta-data of the affected releases (so there's no immediate need for uploading a new release), see
And while at it, the following ones needed upper bounds tightened:
See also https://matrix.hackage.haskell.org/package/heap to get an overview of heap
's install-plan health
{-# RULES "split/merge" forall x. split (merge x) = x #-}
{-# RULES "splitF/split" forall f x. splitF f (split x) = f x #-}
The rules mentioned (above) in Data.Heap.Item
don't have phases defined resulting in unnecessary warnings.
I believe, by default, the GHC pipeline has 3 phases: 0, 1 and 2 in that order.
Please go through the following discussion at Gitlab: BuiltinRules override other rules in some cases.. Specifically, the comment by @simonpj
where he suggests the use of temporary functions.
Maybe something like the following could work in removing the warnings,
{-# INLINE [1] merge' #-}
merge' = merge
{-# INLINE [1] split' #-}
split' = split
{-#
RULES "split'/merge'" forall x. split' (merge' x) = x
RULES "splitF/split'" forall f x. splitF f (split' x) = f x
#-}
And use merge'
and split'
instead of merge
and split
.
This delays inlining built-in class-method rules for merge and split.
Maybe I'll play around with this and let you know :)
Hey,
I need to update the value
for a specific priority
, is this currently possible ?
Cheers
Hi,
The only way I can think of deleting or modifying an element in the heap is to filter
the heap or filter
and insert
.
The problem with this is that the time complexity is O(|N|).
Ideally, the time complexity should be O(log|N|).
I understand that the structure is defined like such and it is difficult to make a delete
or a modify
operation but maybe there is an effective method out there.
Note: By modify
, I mean changing the priority of an element.
Add an instance for semigroup.
Building library for heap-1.0.3..
[1 of 3] Compiling Data.Heap.Internal ( Data/Heap/Internal.hs, dist/build/Data/Heap/Internal.o )
Data/Heap/Internal.hs:69:10: error:
• Could not deduce (Semigroup (HeapT prio val))
arising from the superclasses of an instance declaration
from the context: Ord prio
bound by the instance declaration at Data/Heap/Internal.hs:69:10-46
• In the instance declaration for ‘Monoid (HeapT prio val)’
|
69 | instance (Ord prio) => Monoid (HeapT prio val) where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This package has been removed from the Stackage nightly builds. To restore, please open a PR on the Stackage github repo as usual.
[8 of 8] Compiling Main ( Test.hs, dist/build/heap-tests/heap-tests-tmp/Main.o )
Test.hs:15:10: error:
• The constructor ‘Success’ should have 6 arguments, but has been given 3
• In the pattern: Success _ _ _
In a case alternative:
(Success _ _ _)
-> do putStrLn "Tests for Data.Heap.Internal:" >> Internal.runTests
>> putStrLn ""
putStrLn "Tests for Data.Heap.Item:" >> Item.runTests
>> putStrLn ""
putStrLn "Tests for Data.Heap:" >> Heap.runTests
In a stmt of a 'do' block:
case result of
(Success _ _ _)
-> do putStrLn "Tests for Data.Heap.Internal:" >> Internal.runTests
>> putStrLn ""
putStrLn "Tests for Data.Heap.Item:" >> Item.runTests
>> putStrLn ""
....
_ -> return ()
|
15 | (Success _ _ _) -> do
| ^^^^^^^^^^^^^
I recommend you match on Success{}
instead, which matches the constructor without regard for how many fields the constructor holds.
I was able to reproduce this locally like so:
stack unpack heap-1.0.4 && cd heap-1.0.4
echo 'resolver: nightly-2018-12-22' > stack.yaml
stack build --test --bench --no-run-benchmarks --fast
I'll mark this as an expected test failure for now in Stackage.
[8 of 8] Compiling Main ( Test.hs, dist/build/heap-tests/heap-tests-tmp/Main.o )
Test.hs:12:37: error:
• Couldn't match expected type ‘Args’
with actual type ‘Int -> Args’
• Probable cause: ‘Args’ is applied to too few arguments
In the first argument of ‘quickCheckWithResult’, namely
‘(Args Nothing 1 1 1 True)’
In the expression: quickCheckWithResult (Args Nothing 1 1 1 True)
In a stmt of a 'do' block:
result <- quickCheckWithResult (Args Nothing 1 1 1 True)
$ expectFailure (assert False True)
|
12 | result <- quickCheckWithResult (Args Nothing 1 1 1 True) $ expectFailure (assert False True)
| ^^^^
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.