module Options.Applicative.Arrows (
module Control.Arrow,
A(..),
asA,
runA,
ParserA,
) where
import Control.Arrow
import Control.Category (Category(..))
import Options.Applicative
import Prelude hiding ((.), id)
newtype A f a b = A
{ unA :: f (a -> b) }
asA :: Applicative f => f a -> A f () a
asA x = A $ const <$> x
runA :: Applicative f => A f () a -> f a
runA a = unA a <*> pure ()
instance Applicative f => Category (A f) where
id = A $ pure id
(A f) . (A g) = A $ flip (.) <$> g <*> f
instance Applicative f => Arrow (A f) where
arr = A . pure
first (A f) = A $ first <$> f
type ParserA = A Parser