module Control.Arrow.Util where
import Control.Arrow (Arrow, arr, (&&&), (>>^), (^<<))
constantly :: Arrow a => b -> a c b
constantly :: forall (a :: * -> * -> *) b c. Arrow a => b -> a c b
constantly = (c -> b) -> a c b
forall b c. (b -> c) -> a b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((c -> b) -> a c b) -> (b -> c -> b) -> b -> a c b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> c -> b
forall a b. a -> b -> a
const
{-# INLINE constantly #-}
elementwise :: Arrow a => (c -> d) -> a b c -> a b d
elementwise :: forall (a :: * -> * -> *) c d b.
Arrow a =>
(c -> d) -> a b c -> a b d
elementwise = (c -> d) -> a b c -> a b d
forall (a :: * -> * -> *) c d b.
Arrow a =>
(c -> d) -> a b c -> a b d
(^<<)
elementwise2 :: Arrow a => (c -> d -> e) -> a b c -> a b d -> a b e
elementwise2 :: forall (a :: * -> * -> *) c d e b.
Arrow a =>
(c -> d -> e) -> a b c -> a b d -> a b e
elementwise2 c -> d -> e
op a b c
a1 a b d
a2 = (a b c
a1 a b c -> a b d -> a b (c, d)
forall b c c'. a b c -> a b c' -> a b (c, c')
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& a b d
a2) a b (c, d) -> ((c, d) -> e) -> a b e
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ (c -> d -> e) -> (c, d) -> e
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry c -> d -> e
op