Modif (Attention : ÉCHOUE LA COMPILATION, pour cause de transition) : {lib,jcc,ledger...
[comptalang.git] / lib / Hcompta / Filter / Reduce.hs
index 450d654a6e23d3886047b993573e29314a8b15f8..65097e26633577edb780432bd0f2215b30d8943e 100644 (file)
@@ -25,9 +25,13 @@ module Hcompta.Filter.Reduce where
 
 import           Control.Arrow ((***))
 import           Control.Monad (join)
-import           Data.Maybe (fromJust)
+import           Data.Bool
+import           Data.Either (Either(..))
+import           Data.Functor (Functor(..), (<$>))
+import           Data.Maybe (Maybe(..), fromJust, fromMaybe)
 import qualified Data.List
 import           Data.Map.Strict (Map)
+import           Prelude (($), (.), uncurry)
 
 import           Hcompta.Date (Date)
 import qualified Hcompta.Date as Date
@@ -58,7 +62,7 @@ instance Transaction t
 --   for the given 'Filter_Bool' to filter.
 bool_date :: Dated t => Filter_Bool t -> Simplified Reduce_Date
 bool_date tst =
-       simplify (maybe Any id $ go tst) (Nothing::Maybe Date)
+       simplify (fromMaybe Any $ go tst)
        where
                go :: Dated t
                 => Filter_Bool t
@@ -112,11 +116,11 @@ sieve_date tb si =
                                        Interval.Sieve.intersection s $
                                        Interval.Sieve.singleton $
                                        case to of
-                                        Filter_Ord_Lt o -> fromJust $ Interval.interval (Interval.low bounds) (Interval.Limit Interval.Out o)
-                                        Filter_Ord_Le o -> fromJust $ Interval.interval (Interval.low bounds) (Interval.Limit Interval.In  o)
-                                        Filter_Ord_Eq o -> Interval.point o
-                                        Filter_Ord_Ge o -> fromJust $ Interval.interval (Interval.Limit Interval.In  o) (Interval.high bounds)
-                                        Filter_Ord_Gt o -> fromJust $ Interval.interval (Interval.Limit Interval.Out o) (Interval.high bounds)
+                                        Filter_Ord Lt o -> fromJust $ Interval.interval (Interval.low bounds) (Interval.Limit Interval.Out o)
+                                        Filter_Ord Le o -> fromJust $ Interval.interval (Interval.low bounds) (Interval.Limit Interval.In  o)
+                                        Filter_Ord Eq o -> Interval.point o
+                                        Filter_Ord Ge o -> fromJust $ Interval.interval (Interval.Limit Interval.In  o) (Interval.high bounds)
+                                        Filter_Ord Gt o -> fromJust $ Interval.interval (Interval.Limit Interval.Out o) (Interval.high bounds)
                                         Filter_Ord_Any  -> bounds
                                 Filter_Date_Year (Filter_Interval_In i) ->
                                        Interval.Sieve.intersection s $