Use external strict pair package (use strict-tuple-lens also?)
This commit is contained in:
+9
-7
@@ -1,13 +1,15 @@
|
||||
module FoldlHelp
|
||||
( minimumOn
|
||||
, premapMaybe
|
||||
, module Control.Foldl
|
||||
) where
|
||||
module FoldlHelp (
|
||||
minimumOn,
|
||||
premapMaybe,
|
||||
module Control.Foldl,
|
||||
) where
|
||||
|
||||
import Control.Foldl
|
||||
import MaybeHelp
|
||||
import Data.Strict.Tuple
|
||||
|
||||
--data Maybe' a = Just' !a | Nothing'
|
||||
data Pair a b = !a :!: !b
|
||||
--data Pair a b = !a :!: !b
|
||||
|
||||
minimumOn :: Ord b => (a -> b) -> Fold a (Maybe a)
|
||||
minimumOn f = Fold step Nothing' extract
|
||||
@@ -22,7 +24,7 @@ minimumOn f = Fold step Nothing' extract
|
||||
y = f b
|
||||
|
||||
premapMaybe :: (a -> Maybe b) -> Fold b r -> Fold a r
|
||||
{-# INLINABLE premapMaybe #-}
|
||||
{-# INLINEABLE premapMaybe #-}
|
||||
premapMaybe f (Fold step initial extract) = Fold step' initial extract
|
||||
where
|
||||
step' x a = case f a of
|
||||
|
||||
Reference in New Issue
Block a user