module Data.Vector.Fusion.Util (
Id(..), Box(..), liftBox,
delay_inline, delayed_min
) where
import Data.Stream.Monadic (Box(..), liftBox)
newtype Id a = Id { forall a. Id a -> a
unId :: a }
instance Functor Id where
fmap :: forall a b. (a -> b) -> Id a -> Id b
fmap a -> b
f (Id a
x) = forall a. a -> Id a
Id (a -> b
f a
x)
instance Applicative Id where
pure :: forall a. a -> Id a
pure = forall a. a -> Id a
Id
Id a -> b
f <*> :: forall a b. Id (a -> b) -> Id a -> Id b
<*> Id a
x = forall a. a -> Id a
Id (a -> b
f a
x)
instance Monad Id where
return :: forall a. a -> Id a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
Id a
x >>= :: forall a b. Id a -> (a -> Id b) -> Id b
>>= a -> Id b
f = a -> Id b
f a
x
delay_inline :: (a -> b) -> a -> b
{-# INLINE [0] delay_inline #-}
delay_inline :: forall a b. (a -> b) -> a -> b
delay_inline a -> b
f = a -> b
f
delayed_min :: Int -> Int -> Int
{-# INLINE [0] delayed_min #-}
delayed_min :: Int -> Int -> Int
delayed_min Int
m Int
n = forall a. Ord a => a -> a -> a
min Int
m Int
n