GithubHelp home page GithubHelp logo

bokesan / intervalmap Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 4.0 643 KB

Haskell interval collections

License: BSD 3-Clause "New" or "Revised" License

Haskell 100.00%
haskell haskell-library interval set map hackage tree red-black-tree

intervalmap's Issues

Please add lookupLE and lookupGE

The interface here is close to the standard Data.Map but it lacks lookupLE (lookup less than or equal) and lookupGE (greater or equal). I am using intervals to cover time periods but there are times that no interval covers, so in that case I need to be able to find the closest match on either side. I realise I could use split for this but for what I want I would need to do something like

IMap.split i >>> IMap.findMax *** IMap.findMin $ imap

but it may be possible to do this more efficiently in the library. If it is not, this issue can be closed.

Empty intervals do not have a consistent interpretation with respect to `overlaps` and `intersecting`

Any open or half-open interval with the same lower and upper bound should be considered empty (i.e. (x,x], [x,x) and (x,x)). The function IntervalMap.isEmpty agrees with this interpretation, where IntervalMap.isEmpty (IntervalCO 1 1) is True. However, this is not consistent with the results of IntervalMap.intersecting or IntervalMap.overlaps, since an empty interval should never intersect or overlap with any other interval.

Current behavior: IntervalMap.overlaps (IntervalCO 1 1) (InvervalCO 0 2) is True
Expected behavior: IntervalMap.overlaps (IntervalCO 1 1) (InvervalCO 0 2) should be False

Current behavior :IntervalMap.intersecting (fromList [(IntervalCO 0 2, "0_2")]) (IntervalCO 1 1) is [(IntervalCO 0 2, "0_2")]
Expected behavior: IntervalMap.intersecting (fromList [(IntervalCO 0 2, "0_2")]) (IntervalCO 1 1) should be []

Data.IntervalMap exports Prelude functions instead of its own definitions

I'm sure it's a minor oversight: Is Data.IntervalMap.Strict's lookup function really supposed to take a list of assocs?

import qualified Data.IntervalMap.Strict as IM

fun :: IM.IntervalMap Int String
fun ivmap k v =
  case IM.lookup k ivmap of
    Just _x -> "Good"
    Nothing -> "Bad"

GHC error:

 Couldn't match expected type ‘[(Int, IM.IntervalMap Int String)]'
               with actual type ‘IM.IntervalMap Int String’

Build failure with GHC 8.4

Add semigroup instances.
See also: https://ghc.haskell.org/trac/ghc/wiki/Migration/8.4#SemigroupMonoidsuperclasses

Building library for IntervalMap-0.5.3.1..
[1 of 9] Compiling Data.IntervalMap.Interval ( Data/IntervalMap/Interval.hs, dist/build/Data/IntervalMap/Interval.o )
[2 of 9] Compiling Data.IntervalMap.Generic.Interval ( Data/IntervalMap/Generic/Interval.hs, dist/build/Data/IntervalMap/Generic/Interval.o )
[3 of 9] Compiling Data.IntervalMap.Generic.Base ( Data/IntervalMap/Generic/Base.hs, dist/build/Data/IntervalMap/Generic/Base.o )

Data/IntervalMap/Generic/Base.hs:254:10: error:
    • Could not deduce (Semigroup (IntervalMap i v))
        arising from the superclasses of an instance declaration
      from the context: (Interval i k, Ord i)
        bound by the instance declaration
        at Data/IntervalMap/Generic/Base.hs:254:10-58
    • In the instance declaration for ‘Monoid (IntervalMap i v)’
    |
254 | instance (Interval i k, Ord i) => Monoid (IntervalMap i v) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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.