module Control.Arrow.ArrowNF
where
import Control.Arrow
import Control.Arrow.ArrowList
import Control.DeepSeq
import Control.FlatSeq
strictA :: (Arrow a, NFData b) => a b b
strictA :: a b b
strictA = (b -> b) -> a b b
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((b -> b) -> a b b) -> (b -> b) -> a b b
forall a b. (a -> b) -> a -> b
$ \ b
x -> b -> b -> b
forall a b. NFData a => a -> b -> b
deepseq b
x b
x
class (Arrow a) => ArrowNF a where
rnfA :: (NFData c) => a b c -> a b c
rnfA a b c
f = a b c
f a b c -> (c -> c) -> a b c
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ (\ c
x -> c -> c -> c
forall a b. NFData a => a -> b -> b
deepseq c
x c
x)
{-# INLINE rnfA #-}
class (Arrow a, ArrowList a) => ArrowWNF a where
rwnfA :: (WNFData c) => a b c -> a b c
rwnfA a b c
f = a b c
f a b c -> ([c] -> [c]) -> a b c
forall (a :: * -> * -> *) b c d.
ArrowList a =>
a b c -> ([c] -> [d]) -> a b d
>>. \ [c]
x -> (c -> ()) -> [c] -> ()
forall a. (a -> ()) -> [a] -> ()
rlnf c -> ()
forall a. WNFData a => a -> ()
rwnf [c]
x () -> [c] -> [c]
`seq` [c]
x
{-# INLINE rwnfA #-}
rwnf2A :: (WNFData c) => a b c -> a b c
rwnf2A a b c
f = a b c
f a b c -> ([c] -> [c]) -> a b c
forall (a :: * -> * -> *) b c d.
ArrowList a =>
a b c -> ([c] -> [d]) -> a b d
>>. \ [c]
x -> (c -> ()) -> [c] -> ()
forall a. (a -> ()) -> [a] -> ()
rlnf c -> ()
forall a. WNFData a => a -> ()
rwnf2 [c]
x () -> [c] -> [c]
`seq` [c]
x
{-# INLINE rwnf2A #-}