-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A data type with elements separated by values -- -- A data type with elements separated by values @package separated @version 0.1.2 module Data.Separated.SeparatedCons -- | Prepend a value to a separated-like structure. class (f ~ SeparatedConsF g, g ~ SeparatedConsG f) => SeparatedCons f g where type SeparatedConsF g :: * -> * -> * type SeparatedConsG f :: * -> * -> * where { type family SeparatedConsF g :: * -> * -> *; type family SeparatedConsG f :: * -> * -> *; } (+:) :: SeparatedCons f g => a -> f b a -> g a b module Data.Separated.Separated data Separated a b -- | The isomorphism to a list of pairs of element and separator values. -- --
-- >>> separated # empty -- [] ---- --
-- >>> separated # ('x' +: 6 +: empty)
-- [('x',6)]
--
--
-- -- >>> [] ^. separated -- [] ---- --
-- >>> [(6, [])] ^. separated -- [6,[]] --separated :: Iso [(a, b)] [(c, d)] (Separated a b) (Separated c d) data Separated1 b a -- | The isomorphism to element values interspersed with a separator. -- --
-- >>> separated1 # (single 6) -- (6,[]) ---- --
-- >>> separated1 # (5 +: 'x' +: single 6) -- (5,['x',6]) ---- --
-- >>> (6, empty) ^. separated1 -- [6] ---- --
-- >>> (5, 'x' +- 6) ^. separated1 -- [5,'x',6] --separated1 :: Iso (a, Separated s a) (b, Separated t b) (Separated1 a s) (Separated1 b t) -- | A lens on the first element value. -- --
-- >>> single 7 ^. separated1Head -- 7 ---- --
-- single x ^. separated1Head == (x :: Int) --separated1Head :: Lens (Separated1 a t) (Separated1 a t) a a -- | A lens on the tail. -- --
-- (d +: e +: single x) ^. separated1Tail == e +: x +: empty --separated1Tail :: Lens (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) empty :: Separated s a -- | One element and one separator. -- --
-- >>> 7 +- "abc" -- [7,"abc"] ---- --
-- >>> 7 +: "abc" +: 8 +- "def" -- [7,"abc",8,"def"] --(+-) :: s -> a -> Separated s a infixl 9 +- -- | Zero element values interspersed with one element. -- --
-- >>> single 4 -- [4] ---- --
-- single x ^. separated1Tail == empty --single :: a -> Separated1 a s -- | The isomorphism that shuffles the elements and separators one -- position. -- --
-- >>> shift # ([], 6) -- [6] ---- --
-- >>> shift # ([(5, 'x')], 6) -- [5,'x',6] ---- --
-- >>> single 6 ^. shift -- ([],6) ---- --
-- >>> (5 +: 'x' +: single 6) ^. shift -- ([(5,'x')],6) --shift :: Iso (Separated1 a s) (Separated1 b t) ([(a, s)], a) ([(b, t)], b) -- | Append two lists of separated values to produce a list of pairs of -- separator and element values. -- --
-- >>> single 7 .++. single 'a' -- [7,'a'] ---- -- a +: single 7 .++. single b -- [a,7,b] -- --
-- a +: (b :: Separated Int Int) == a +: b -- (a +: (b .++. c)) == ((a +: b) .++ c) --(.++.) :: Separated1 s a -> Separated1 a s -> Separated s a infixr 5 .++. -- | Append element values interspersed with a separator to a list of pairs -- of separator and element values. -- --
-- >>> empty ++. single 7 -- [7] ---- --
-- >>> empty ++. 6 +: 'x' +: single 7 -- [6,'x',7] ---- --
-- >>> 'w' +: empty ++. 6 +: 'x' +: single 7 -- ['w',6,'x',7] --(++.) :: Separated s a -> Separated1 s a -> Separated1 s a infixr 5 ++. -- | Append a list of pairs of separator and element values to element -- values interspersed with a separator. -- --
-- >>> single 7 .++ empty -- [7] ---- --
-- >>> single 6 .++ 'x' +: 7 +: empty -- [6,'x',7] ---- --
-- >>> 'w' +: single 6 .++ 'x' +: 7 +: empty -- ['w',6,'x',7] --(.++) :: Separated1 a s -> Separated s a -> Separated1 a s infixr 5 .++ -- |
-- >>> parse (separatedBy (char ',') digit) "test" "" -- Right [] ---- --
-- >>> isLeft (parse (separatedBy (char ',') digit) "test" ",") -- True ---- --
-- >>> parse (separatedBy (char ',') digit) "test" ",1" -- Right [',','1'] ---- --
-- >>> isLeft (parse (separatedBy (char ',') digit) "test" ",1,") -- True ---- --
-- >>> parse (separatedBy (char ',') digit) "test" ",1,2,3,4,5" -- Right [',','1',',','2',',','3',',','4',',','5'] --separatedBy :: Alternative f => f a -> f b -> f (Separated a b) -- |
-- >>> isLeft (parse (separatedBy1 (char ',') digit) "test" "") -- True ---- --
-- >>> parse (separatedBy1 (char ',') digit) "test" "," -- Right [','] ---- --
-- >>> isLeft (parse (separatedBy1 (char ',') digit) "test" ",1") -- True ---- --
-- >>> parse (separatedBy1 (char ',') digit) "test" ",1," -- Right [',','1',','] ---- --
-- >>> parse (separatedBy1 (char ',') digit) "test" ",1,2,3,4,5," -- Right [',','1',',','2',',','3',',','4',',','5',','] --separatedBy1 :: Alternative f => f b -> f a -> f (Separated1 b a) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Data.Separated.Separated.Separated1 b a) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Separated.Separated.Separated1 b a) instance Data.Separated.Separated.Separated a0 b0 ~ t0 => Control.Lens.Wrapped.Rewrapped (Data.Separated.Separated.Separated a1 b1) t0 instance Control.Lens.Wrapped.Wrapped (Data.Separated.Separated.Separated a0 b0) instance Control.Lens.Iso.Swapped Data.Separated.Separated.Separated instance Data.Bifunctor.Bifunctor Data.Separated.Separated.Separated instance Data.Bifoldable.Bifoldable Data.Separated.Separated.Separated instance Data.Bitraversable.Bitraversable Data.Separated.Separated.Separated instance GHC.Base.Functor (Data.Separated.Separated.Separated a) instance Data.Semigroup.Semigroup a => Data.Functor.Bind.Class.Apply (Data.Separated.Separated.Separated a) instance (Data.Semigroup.Semigroup a, GHC.Base.Monoid a) => GHC.Base.Applicative (Data.Separated.Separated.Separated a) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Separated.Separated.Separated a b) instance Data.Semigroup.Semigroup (Data.Separated.Separated.Separated a b) instance GHC.Base.Monoid (Data.Separated.Separated.Separated a b) instance Data.Separated.SeparatedCons.SeparatedCons Data.Separated.Separated.Separated1 Data.Separated.Separated.Separated instance Data.Bifunctor.Bifunctor Data.Separated.Separated.Separated1 instance GHC.Base.Functor (Data.Separated.Separated.Separated1 b) instance Data.Semigroup.Semigroup b => Data.Functor.Bind.Class.Apply (Data.Separated.Separated.Separated1 b) instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (Data.Separated.Separated.Separated1 b a) instance (Data.Semigroup.Semigroup b, GHC.Base.Monoid b) => GHC.Base.Applicative (Data.Separated.Separated.Separated1 b) instance Data.Separated.SeparatedCons.SeparatedCons Data.Separated.Separated.Separated Data.Separated.Separated.Separated1 instance (GHC.Classes.Ord b, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Separated.Separated.Separated a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Separated.Separated.Separated a b) module Data.Separated