
Hi, Could you please explain, why numerator and denominator add an extra layer of laziness? Best regards, Andrew
17 сент. 2019 г., в 15:54, Zemyla
написал(а): Using the numerator and denominator functions in Data.Ratio adds an extra layer of laziness to functions that have to work with Ratios (especially Rationals). I think it'd be convenient if there were a pattern synonym exported from the safe Data.Ratio:
pattern n :% d <- (n GHC.Ratio.:% d) where n :% d = n % d
This way, destructuring is as fast as if you were to import GHC.Ratio directly, but it can't be used to create invalid Ratios.
The only disadvantage is that using the :% to destructure it requires an Integral constraint on the value, but 99% of the time, the value will be Integer anyway, and even in the remaining 1% you still can't construct a Ratio a without an Integral a constraint in safe code anyway, so it shouldn't matter. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries