New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract away the interface of Interval from the rest of the module #2
Conversation
Ping? |
Thank you for your PR, and sorry for the late reply.
Do you worry about moving the definition of |
src/Data/Interval.hs
Outdated
, -- | 'upperBound' of the interval and whether it is included in the interval. | ||
-- The result is convenient to use as an argument for 'interval'. | ||
upperBound' :: !(Extended r, Bool) | ||
} deriving (Eq, Generic, Data, Typeable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR replaces hand-written Data
instance with the one generated by GHC.
But doesn’t the generated one allow constructing unnormalized interval value (e.g. through gmapT
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that following y
becomes unnormalized interval where lower bounds is Finite (-1)
while upper bound is Finite 0
.
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Interval as Interval
import Data.Data
import Data.Maybe
f :: Data a => a -> a
f x = fromJust $ do
(x' :: Interval.Extended Integer, b::Bool) <- cast x
cast (fmap negate x', b)
x :: Interval.Interval Integer
x = 0 Interval.<=..<= 1
y :: Interval.Interval Integer
y = gmapT f x
So could you revert this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, my bad.
Other changes looks good to me. |
Thanks, please take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you very much for your contribution. |
I've been playing with different implementations of
Interval
and it appeared to be useful to do not pattern-match onInterval
constructor in the body of the module, relying solely onlowerBound'
/upperBound'
/empty
/interval
.It would be even better to move definition of
Interval
to a separate module, but it is difficult because ofLattice
instances.What is your opinion on this?