Code Monkey home page Code Monkey logo

data-interval's Introduction

data-interval

Build Status (GitHub Actions) Hackage Hackage Deps Coverage Status License

Interval datatype, interval arithmetic, and interval-based containers for Haskell.

Unlike the intervals package, this package provides both open and closed intervals and is intended to be used with Rational.

data-interval's People

Contributors

bodigrim avatar googleson78 avatar marcosh avatar msakai avatar ncfavier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

data-interval's Issues

Self-explaining type for interval boundaries

I noticed that I repeatedly forget the meaning of Bool in (Extended r, Bool): does it stand for an open interval or for a closed one? Surely, one can always refer to haddocks, but maybe it is worth to make this parameter self-explaining? Like

data Strictness = Strict | NonStrict

or

data Boundary = Open | Closed 

width of open integer intervals is not right

I checked out the master branch today to make sure that #38 is in, but I still get something wrong. Maybe I'm not getting something?

λ> import qualified Data.IntegerInterval as II
λ> II.width $ Finite 3 II.<..< Finite (5::Integer)
0

I think the width of this interval should be 1. Is that not right?

Even more surprising is the result for regular intervals:

λ> import Data.Interval
λ> width $ Finite 3 <..< Finite (5::Int)
2

How?…

lattices-2.2 not accepted

lattices-2.2 is the first release compatible with base-compat-0.13, which e.g. cabal-plan-0.7.3.0 requires.

TestIntervalRelation failure

$ stack test --ta '--hide-successes --quickcheck-tests 100000 -p TestIntervalRelation'

  TestIntervalRelation
    invert inverts relation: FAIL (0.08s)
      *** Failed! Falsified (after 20701 tests):
      Finite (0 % 1) <=..<= Finite (0 % 1)
      Finite (0 % 1) <..< PosInf
      JustBefore /= JustAfter
      Use --quickcheck-replay=413814 to reproduce.

@marcosh could you possibly take a look?

Build failures with GHC >= 9 in v0.1.0, v0.2.0, v1.3.1, v2.0.0 and v2.0.1

src/Data/Interval.hs:405:20: error:
    Ambiguous occurrence ‘singleton’
    It could refer to
       either ‘Data.List.singleton’,
              imported from ‘Data.List’ at src/Data/Interval.hs:63:1-30
              (and originally defined in ‘base-4.15.0.0:Data.OldList’)
           or ‘Data.Interval.singleton’,
              defined at src/Data/Interval.hs:184:1
    |
405 |   fromRational r = singleton (fromRational r)
    |                    ^^^^^^^^^

As a Hackage trustee, I've revised these versions to remove these broken build plans. See e.g. https://hackage.haskell.org/package/data-interval-2.0.1/revisions/.

Data.Vector.Unboxed instances

#7

This representation also allows to write an instance of Data.Vector.Unboxed, which will require only (2 words + 1 byte) per value. (I cannot include it into PR, because currently data-interval does not depend on vector).

@Bodigrim, do you want to include the instances in version 2.0.0?

put it on stackage?

Could you put this package to stackage?

I think this package (and its dependency extended-reals) is useful for many applications and libraries and they are well-maintained.

CI breaks against GHC 9.2.1 due to lattices-1.2.1.1

Error :

Algebra/PartialOrd.hs:47:43: error:
    • Data.Map.fold is gone. Use foldr.
cabal-3.6.2.0: Failed to build lattices-1.2.1.1. See the build log above for details.

I suggest importing a newer version of 'lattices', which doesn't use Data.Map.fold

Corner cases of `relate`

> (NegInf<..<=0) `relate` (0<..<PosInf)
JustBefore -- I'd expect Before
> (NegInf<..<=0) `relate` (0<=..<PosInf)
Overlaps   -- I'd expect JustBefore

CC @marcosh what do you think?

lookup value and the/a piece-wise constant component around it

I am sampling sections of a piece-wise constant function encoded as an IntervalMap, and for efficiency reasons it would be useful to have a lookup function that also reported the maximal (or just some non-trivial) interval around the query point on which the IntervalMap is constant. There is a quickly cooked up prototype here: tilowiklundSensmetry@8e0d144 that I am guessing would give a (not necessarily maximal) such interval, but I am not certain enough about the semantics of IntervalMap to say whether it is correct.

IntervalSet.insert is incorrect

case_insert_zero =
  IntervalSet.insert zero (IntervalSet.complement $ IntervalSet.singleton zero) @?= IntervalSet.whole
  where
    zero :: Interval Rational
    zero = 0 <=..<= 0

fails with

data-interval test suite
  TestIntervalSet
    insert zero:                                                             FAIL
      test/TestIntervalSet.hs:114:
      expected: fromList [NegInf <..< PosInf]
       but got: fromList [NegInf <..< Finite (0 % 1),Finite (0 % 1) <=..< PosInf]

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.