on master help sign in
change the signature of fromStrictMaybe and rename it
233ea77Harendra Kumar
src/Streamly/Internal/Data/Fold.hs+3−3
@@ -348,7 +348,7 @@ transform (Pipe pstep1 pstep2 pinitial) (Fold fstep finitial fextract) =
348-- from the 'Foldable', the result is 'None' for empty containers.
348-- from the 'Foldable', the result is 'None' for empty containers.
349{-# INLINABLE _Fold1 #-}
349{-# INLINABLE _Fold1 #-}
350_Fold1 :: Monad m => (a -> a -> a) -> Fold m a (Maybe a)
350_Fold1 :: Monad m => (a -> a -> a) -> Fold m a (Maybe a)
351−_Fold1 step = Fold step_ (return Nothing') fromStrictMaybe
351+_Fold1 step = Fold step_ (return Nothing') (return . toMaybe)
352 where
352 where
353 step_ mx a = return $ Just' $
353 step_ mx a = return $ Just' $
354 case mx of
354 case mx of
@@ -692,7 +692,7 @@ head = _Fold1 const
692-- @since 0.7.0
692-- @since 0.7.0
693{-# INLINABLE find #-}
693{-# INLINABLE find #-}
694find :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
694find :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
695−find predicate = Fold step (return Nothing') fromStrictMaybe
695+find predicate = Fold step (return Nothing') (return . toMaybe)
696 where
696 where
697 step x a = return $
697 step x a = return $
698 case x of
698 case x of
@@ -707,7 +707,7 @@ find predicate = Fold step (return Nothing') fromStrictMaybe
707-- @since 0.7.0
707-- @since 0.7.0
708{-# INLINABLE lookup #-}
708{-# INLINABLE lookup #-}
709lookup :: (Eq a, Monad m) => a -> Fold m (a,b) (Maybe b)
709lookup :: (Eq a, Monad m) => a -> Fold m (a,b) (Maybe b)
710−lookup a0 = Fold step (return Nothing') fromStrictMaybe
710+lookup a0 = Fold step (return Nothing') (return . toMaybe)
711 where
711 where
712 step x (a,b) = return $
712 step x (a,b) = return $
713 case x of
713 case x of
src/Streamly/Internal/Data/Strict.hs+5−5
@@ -23,7 +23,7 @@ module Streamly.Internal.Data.Strict
23 , Tuple3' (..)
23 , Tuple3' (..)
24 , Tuple4' (..)
24 , Tuple4' (..)
25 , Maybe' (..)
25 , Maybe' (..)
26− , fromStrictMaybe
26+ , toMaybe
27 , Either' (..)
27 , Either' (..)
28 )
28 )
29where
29where
@@ -46,10 +46,10 @@ data Maybe' a = Just' !a | Nothing' deriving Show
46-- XXX perhaps we can use a type class having fromStrict/toStrict operations.
46-- XXX perhaps we can use a type class having fromStrict/toStrict operations.
47--
47--
48-- | Convert strict Maybe' to lazy Maybe
48-- | Convert strict Maybe' to lazy Maybe
49−{-# INLINABLE fromStrictMaybe #-}
49+{-# INLINABLE toMaybe #-}
50−fromStrictMaybe :: Monad m => Maybe' a -> m (Maybe a)
50+toMaybe :: Maybe' a -> Maybe a
51−fromStrictMaybe Nothing' = return $ Nothing
51+toMaybe Nothing' = Nothing
52−fromStrictMaybe (Just' a) = return $ Just a
52+toMaybe (Just' a) = Just a
53
53
54-------------------------------------------------------------------------------
54-------------------------------------------------------------------------------
55-- Either
55-- Either