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.
Interval datatype, interval arithmetic, and interval-based containers for Haskell
License: Other
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.
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
I propose to do it alongside with other breaking changes.
lattices
just released version 2, which drops several typeclasses and, as a result, breaks the compilation of data-interval
. I reported an issue with hackage-trustees to make a revision to the bounds here: haskell-infra/hackage-trustees#226
But this should probably be fixed here (and maybe updated for lattices-2
).
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 is the first release compatible with base-compat-0.13, which e.g. cabal-plan-0.7.3.0 requires.
$ 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?
isSingleton exists in the code for Data.Interval, but is not exported.
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/.
> relate (0 <..< 1) (0 <=..<= 1)
Starts
My understanding is that this should return During
instead. CC @marcosh
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.
I recently implemented my own version of the possible relations occurring between intervals in https://github.com/marcosh/availer/blob/master/src/Availer/Relation.hs.
As suggested by @Bodigrim on reddit, it could be interesting to add this to data-interval
. Would you be interested in a PR for this?
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
> (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?
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.
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]
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.