module Control.Applicative.Combinators.NonEmpty
( some,
endBy1,
someTill,
sepBy1,
sepEndBy1,
)
where
import Control.Applicative hiding (some)
import qualified Control.Applicative.Combinators as C
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NE
some :: Alternative m => m a -> m (NonEmpty a)
some :: m a -> m (NonEmpty a)
some m a
p = [a] -> NonEmpty a
forall a. [a] -> NonEmpty a
NE.fromList ([a] -> NonEmpty a) -> m [a] -> m (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
C.some m a
p
{-# INLINE some #-}
endBy1 :: Alternative m => m a -> m sep -> m (NonEmpty a)
endBy1 :: m a -> m sep -> m (NonEmpty a)
endBy1 m a
p m sep
sep = [a] -> NonEmpty a
forall a. [a] -> NonEmpty a
NE.fromList ([a] -> NonEmpty a) -> m [a] -> m (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m sep -> m [a]
forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
C.endBy1 m a
p m sep
sep
{-# INLINE endBy1 #-}
someTill :: Alternative m => m a -> m end -> m (NonEmpty a)
someTill :: m a -> m end -> m (NonEmpty a)
someTill m a
p m end
end = [a] -> NonEmpty a
forall a. [a] -> NonEmpty a
NE.fromList ([a] -> NonEmpty a) -> m [a] -> m (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m end -> m [a]
forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
C.someTill m a
p m end
end
{-# INLINE someTill #-}
sepBy1 :: Alternative m => m a -> m sep -> m (NonEmpty a)
sepBy1 :: m a -> m sep -> m (NonEmpty a)
sepBy1 m a
p m sep
sep = [a] -> NonEmpty a
forall a. [a] -> NonEmpty a
NE.fromList ([a] -> NonEmpty a) -> m [a] -> m (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m sep -> m [a]
forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
C.sepBy1 m a
p m sep
sep
{-# INLINE sepBy1 #-}
sepEndBy1 :: Alternative m => m a -> m sep -> m (NonEmpty a)
sepEndBy1 :: m a -> m sep -> m (NonEmpty a)
sepEndBy1 m a
p m sep
sep = [a] -> NonEmpty a
forall a. [a] -> NonEmpty a
NE.fromList ([a] -> NonEmpty a) -> m [a] -> m (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m sep -> m [a]
forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
C.sepEndBy1 m a
p m sep
sep
{-# INLINE sepEndBy1 #-}