Git Product home page Git Product logo

heap's Issues

mandatory dependency on QuickCheck

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).

Compile error with base < 4.6

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

Adding phase to the RULES

{-# 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.

CaptureRULES

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 :)

An effective remove and modify operation

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.

Build failure with ghc 8.4

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.

heap-1.0.4 test suite build failure with QuickCheck 2.12

[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.

Test suite build failure

[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)
   |                                     ^^^^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.