Stability | unstable |
---|---|
Safe Haskell | Safe |
Language | Haskell2010 |
- Types, EqN?/ShowN?/(Bi)Functor/Foldable1?/Traversable1?
- Digit operations.
- Node operations.
- Tree rotations
- (Un)conses/snocs for TwoFingerOddA.
- (Un)conses/snocs for TwoFingerOddE.
- (Un)conses/snocs for TwoFingerEvenE.
- (Un)conses/snocs for TwoFingerEvenA.
- Monad and Applicative instances, and related operations
- Construction and deconstruction of TwoFingerOddA.
- Construction of TwoFingerOddE
- Concatenation of TwoFingerOddA.
- Concatenation of TwoFingerEvenE.
- Concatenation of TwoFingerEvenA.
- Monoid actions
- QuickCheck stuff.
- Aligning/zipping.
- Creating infinite sequences.
This is an internal module and not subject to the PVP. It may receive arbitrary changes at any time and between any two releases. Import from Q4C12.TwoFinger instead, unless you really need the gory details, and, in that case, you must depend on the exact version of this package. (If you do need them, please file a bug so that, hopefully, your use-case can be accomplished through the public interface.)
- (<.*>) :: Apply f => f (a -> b) -> MaybeApply f a -> f b
- (<*.>) :: Apply f => MaybeApply f (a -> b) -> f a -> f b
- traverseDefault :: (Applicative f, Traversable1 t) => (a -> f a') -> t a -> f (t a')
- bitraverseDefault :: (Applicative f, Bitraversable1 t) => (a -> f a') -> (b -> f b') -> t a b -> f (t a' b')
- data Digit e a
- data Node e a
- data TwoFingerOddA e a
- = EmptyOddA a
- | SingleOddA a e a
- | DeepOddA a !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a) a
- firstOddA :: Functor f => (a -> f a) -> TwoFingerOddA e a -> f (TwoFingerOddA e a)
- lastOddA :: Functor f => (a -> f a) -> TwoFingerOddA e a -> f (TwoFingerOddA e a)
- data TwoFingerOddE e a
- = SingleOddE e
- | DeepOddE !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a)
- data TwoFingerEvenE e a
- = EmptyEvenE
- | SingleEvenE e a
- | DeepEvenE !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a) a
- data TwoFingerEvenA e a
- = EmptyEvenA
- | SingleEvenA a e
- | DeepEvenA a !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a)
- digitToTree :: Digit e a -> TwoFingerOddE e a
- digitCons :: e -> a -> Digit e a -> Either (Digit e a, a, Node e a) (Digit e a)
- digitSnoc :: Digit e a -> a -> e -> Either (Node e a, a, Digit e a) (Digit e a)
- digitUncons :: Digit e a -> (e, Maybe (a, Digit e a))
- digitUnsnoc :: Digit e a -> (Maybe (Digit e a, a), e)
- nodeToDigit :: Node e a -> Digit e a
- rotl :: TwoFingerOddA (Node e a) a -> Digit e a -> TwoFingerEvenA e a
- rotr :: Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerEvenE e a
- consOddA :: a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a
- snocOddA :: TwoFingerOddA e a -> e -> a -> TwoFingerOddA e a
- unconsOddA :: TwoFingerOddA e a -> Either a ((a, e), TwoFingerOddA e a)
- unsnocOddA :: TwoFingerOddA e a -> Either a (TwoFingerOddA e a, (e, a))
- halfconsOddA :: e -> TwoFingerOddA e a -> TwoFingerEvenE e a
- halfsnocOddA :: TwoFingerOddA e a -> e -> TwoFingerEvenA e a
- halfunconsOddA :: TwoFingerOddA e a -> (a, TwoFingerEvenE e a)
- halfunsnocOddA :: TwoFingerOddA e a -> (TwoFingerEvenA e a, a)
- consOddE :: e -> a -> TwoFingerOddE e a -> TwoFingerOddE e a
- snocOddE :: TwoFingerOddE e a -> a -> e -> TwoFingerOddE e a
- unconsOddE :: TwoFingerOddE e a -> Either e ((e, a), TwoFingerOddE e a)
- unsnocOddE :: TwoFingerOddE e a -> Either e (TwoFingerOddE e a, (a, e))
- halfconsOddE :: a -> TwoFingerOddE e a -> TwoFingerEvenA e a
- halfsnocOddE :: TwoFingerOddE e a -> a -> TwoFingerEvenE e a
- halfunconsOddE :: TwoFingerOddE e a -> (e, TwoFingerEvenA e a)
- halfunsnocOddE :: TwoFingerOddE e a -> (TwoFingerEvenE e a, e)
- consEvenE :: e -> a -> TwoFingerEvenE e a -> TwoFingerEvenE e a
- snocEvenE :: TwoFingerEvenE e a -> e -> a -> TwoFingerEvenE e a
- unconsEvenE :: TwoFingerEvenE e a -> Maybe ((e, a), TwoFingerEvenE e a)
- unsnocEvenE :: TwoFingerEvenE e a -> Maybe (TwoFingerEvenE e a, (e, a))
- halfconsEvenE :: a -> TwoFingerEvenE e a -> TwoFingerOddA e a
- halfsnocEvenE :: TwoFingerEvenE e a -> e -> TwoFingerOddE e a
- halfunconsEvenE :: TwoFingerEvenE e a -> Maybe (e, TwoFingerOddA e a)
- halfunsnocEvenE :: TwoFingerEvenE e a -> Maybe (TwoFingerOddE e a, a)
- consEvenA :: a -> e -> TwoFingerEvenA e a -> TwoFingerEvenA e a
- snocEvenA :: TwoFingerEvenA e a -> a -> e -> TwoFingerEvenA e a
- unconsEvenA :: TwoFingerEvenA e a -> Maybe ((a, e), TwoFingerEvenA e a)
- unsnocEvenA :: TwoFingerEvenA e a -> Maybe (TwoFingerEvenA e a, (a, e))
- halfconsEvenA :: e -> TwoFingerEvenA e a -> TwoFingerOddE e a
- halfsnocEvenA :: TwoFingerEvenA e a -> a -> TwoFingerOddA e a
- halfunconsEvenA :: TwoFingerEvenA e a -> Maybe (a, TwoFingerOddE e a)
- halfunsnocEvenA :: TwoFingerEvenA e a -> Maybe (TwoFingerOddA e a, e)
- joinOddA :: TwoFingerOddA (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerOddA e a
- joinOddE :: TwoFingerOddE (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerOddE e a
- joinEvenA :: TwoFingerEvenA (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerEvenA e a
- joinEvenE :: TwoFingerEvenE (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerEvenE e a
- singletonOddA :: a -> TwoFingerOddA e a
- unitOddA :: (Monoid a, Semigroup a) => e -> TwoFingerOddA e a
- onlyOddA :: TwoFingerOddA e a -> Maybe a
- interleavingOddA :: e -> NonEmpty a -> TwoFingerOddA e a
- singletonOddE :: e -> TwoFingerOddE e a
- appendOddA0 :: Semigroup a => TwoFingerOddA e a -> TwoFingerOddA e a -> TwoFingerOddA e a
- addDigits0 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a
- appendOddA1 :: TwoFingerOddA e a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a
- addDigits1 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a
- appendOddA2 :: TwoFingerOddA e a -> e -> a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a
- addDigits2 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a
- appendOddA3 :: TwoFingerOddA e a -> e -> a -> e -> a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a
- addDigits3 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> e -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a
- appendOddA4 :: TwoFingerOddA e a -> e -> a -> e -> a -> e -> a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a
- addDigits4 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> e -> a -> e -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a
- appendEvenE :: TwoFingerEvenE e a -> TwoFingerEvenE e a -> TwoFingerEvenE e a
- appendEvenA :: TwoFingerEvenA e a -> TwoFingerEvenA e a -> TwoFingerEvenA e a
- appendOddAEvenE :: TwoFingerOddA e a -> TwoFingerEvenE e a -> TwoFingerOddA e a
- appendEvenAOddA :: TwoFingerEvenA e a -> TwoFingerOddA e a -> TwoFingerOddA e a
- appendOddAOddE :: TwoFingerOddA e a -> TwoFingerOddE e a -> TwoFingerEvenA e a
- appendOddEOddA :: TwoFingerOddE e a -> TwoFingerOddA e a -> TwoFingerEvenE e a
- appendOddEEvenA :: TwoFingerOddE e a -> TwoFingerEvenA e a -> TwoFingerOddE e a
- appendEvenEOddE :: TwoFingerEvenE e a -> TwoFingerOddE e a -> TwoFingerOddE e a
- genDigit :: Gen e -> Gen a -> Gen (Digit e a)
- genNode :: Gen e -> Gen a -> Gen (Node e a)
- genOddA :: Gen e -> Gen a -> Int -> Gen (TwoFingerOddA e a)
- shrinkOddA :: TwoFingerOddA e a -> [TwoFingerOddA e a]
- shrinkOddE :: TwoFingerOddE e a -> [TwoFingerOddE e a]
- shrinkEvenA :: TwoFingerEvenA e a -> [TwoFingerEvenA e a]
- shrinkEvenE :: TwoFingerEvenE e a -> [TwoFingerEvenE e a]
- newtype AnyOddA = AnyOddA {
- getAnyOddA :: TwoFingerOddA Int [Int]
- newtype AnyOddE = AnyOddE {
- getAnyOddE :: TwoFingerOddE Int [Int]
- newtype AnyEvenA = AnyEvenA {
- getAnyEvenA :: TwoFingerEvenA Int [Int]
- newtype AnyEvenE = AnyEvenE {
- getAnyEvenE :: TwoFingerEvenE Int [Int]
- alignLeftOddAOddA :: TwoFingerOddA e a -> TwoFingerOddA e' a' -> (TwoFingerOddA (e, e') (a, a'), Either (TwoFingerEvenE e a) (TwoFingerEvenE e' a'))
- alignLeftOddAEvenA :: TwoFingerOddA e a -> TwoFingerEvenA e' a' -> Either (TwoFingerEvenA (e, e') (a, a'), TwoFingerOddA e a) (TwoFingerOddA (e, e') (a, a'), TwoFingerOddE e' a')
- alignLeftEvenAEvenA :: TwoFingerEvenA e a -> TwoFingerEvenA e' a' -> (TwoFingerEvenA (e, e') (a, a'), Either (TwoFingerEvenA e a) (TwoFingerEvenA e' a'))
- alignLeftOddEOddE :: TwoFingerOddE e a -> TwoFingerOddE e' a' -> (TwoFingerOddE (e, e') (a, a'), Either (TwoFingerEvenA e a) (TwoFingerEvenA e' a'))
- alignLeftOddEEvenE :: TwoFingerOddE e a -> TwoFingerEvenE e' a' -> Either (TwoFingerEvenE (e, e') (a, a'), TwoFingerOddE e a) (TwoFingerOddE (e, e') (a, a'), TwoFingerOddA e' a')
- alignLeftEvenEEvenE :: TwoFingerEvenE e a -> TwoFingerEvenE e' a' -> (TwoFingerEvenE (e, e') (a, a'), Either (TwoFingerEvenE e a) (TwoFingerEvenE e' a'))
- takeNodeLeft :: (Stream a -> es -> (e, Stream a, es)) -> Stream a -> es -> (Node e a, Stream a, es)
- takeNodeRight :: (es -> Stream a -> (e, es, Stream a)) -> es -> Stream a -> (Node e a, es, Stream a)
- infiniteOddA' :: (Stream a -> Stream e -> (Node e' a, Stream a, Stream e)) -> (Stream e -> Stream a -> (Node e' a, Stream e, Stream a)) -> Stream a -> Stream e -> Stream e -> Stream a -> TwoFingerOddA e' a
- repeatOddA :: a -> e -> TwoFingerOddA e a
- infiniteOddA :: Stream a -> Stream e -> Stream e -> Stream a -> TwoFingerOddA e a
- repeatOddE :: e -> a -> TwoFingerOddE e a
- infiniteOddE :: Stream e -> Stream a -> Stream a -> Stream e -> TwoFingerOddE e a
- repeatEvenA :: a -> e -> TwoFingerEvenA e a
- infiniteEvenA :: Stream a -> Stream e -> Stream a -> Stream e -> TwoFingerEvenA e a
- repeatEvenE :: e -> a -> TwoFingerEvenE e a
- infiniteEvenE :: Stream e -> Stream a -> Stream e -> Stream a -> TwoFingerEvenE e a
Documentation
>>>
import Data.List (unfoldr)
>>>
import Data.Tuple (swap)
>>>
import Control.Lens (over, view)
>>>
let hush = either (const Nothing) Just
(<.*>) :: Apply f => f (a -> b) -> MaybeApply f a -> f b infixl 4 Source #
(<*.>) :: Apply f => MaybeApply f (a -> b) -> f a -> f b infixl 4 Source #
traverseDefault :: (Applicative f, Traversable1 t) => (a -> f a') -> t a -> f (t a') Source #
bitraverseDefault :: (Applicative f, Bitraversable1 t) => (a -> f a') -> (b -> f b') -> t a b -> f (t a' b') Source #
Types, EqN?/ShowN?/(Bi)Functor/Foldable1?/Traversable1?
Bifunctor Digit Source # | |
Bitraversable Digit Source # | |
Bifoldable Digit Source # | |
Bitraversable1 Digit Source # | |
Bifoldable1 Digit Source # | |
Functor (Digit e) Source # | |
Foldable (Digit e) Source # | |
Traversable (Digit e) Source # | |
Generic (Digit e a) Source # | |
(NFData e, NFData a) => NFData (Digit e a) Source # | |
type Rep (Digit e a) Source # | |
Bifunctor Node Source # | |
Bitraversable Node Source # | |
Bifoldable Node Source # | |
Bitraversable1 Node Source # | |
Bifoldable1 Node Source # | |
Functor (Node e) Source # | |
Foldable (Node e) Source # | |
Traversable (Node e) Source # | |
Traversable1 (Node e) Source # | |
Foldable1 (Node e) Source # | |
(Eq a, Eq e) => Eq (Node e a) Source # | |
Generic (Node e a) Source # | |
(NFData e, NFData a) => NFData (Node e a) Source # | |
type Rep (Node e a) Source # | |
data TwoFingerOddA e a Source #
Isomorphic to a, (e, a)*
EmptyOddA a | |
SingleOddA a e a | |
DeepOddA a !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a) a |
firstOddA :: Functor f => (a -> f a) -> TwoFingerOddA e a -> f (TwoFingerOddA e a) Source #
Access the first a
of a
. \(O(1)\). This
type is TwoFingerOddA
e aLens' (
in disguise.TwoFingerOddA
e a) a
>>>
view firstOddA (consOddA 3 True $ singletonOddA 15)
3
lastOddA :: Functor f => (a -> f a) -> TwoFingerOddA e a -> f (TwoFingerOddA e a) Source #
Access the last a
of a
. \(O(1)\). This type
is TwoFingerOddA
e aLens' (
in disguise.TwoFingerOddA
e a) a
>>>
over lastOddA (+ 5) (consOddA 3 True $ singletonOddA 15)
consOddA 3 True (singletonOddA 20)
data TwoFingerOddE e a Source #
Isomorphic to e, (a, e)*
SingleOddE e | |
DeepOddE !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a) |
Eq2 TwoFingerOddE Source # | |
Show2 TwoFingerOddE Source # | |
Bifunctor TwoFingerOddE Source # | |
Bitraversable TwoFingerOddE Source # | |
Bifoldable TwoFingerOddE Source # | |
Functor (TwoFingerOddE e) Source # | |
Foldable (TwoFingerOddE e) Source # | |
Traversable (TwoFingerOddE e) Source # | |
Eq e => Eq1 (TwoFingerOddE e) Source # | |
Show e => Show1 (TwoFingerOddE e) Source # | |
(Eq e, Eq a) => Eq (TwoFingerOddE e a) Source # | |
(Show e, Show a) => Show (TwoFingerOddE e a) Source # | |
Generic (TwoFingerOddE e a) Source # | |
(NFData e, NFData a) => NFData (TwoFingerOddE e a) Source # | |
type Rep (TwoFingerOddE e a) Source # | |
data TwoFingerEvenE e a Source #
Isomorphic to (e, a)*
EmptyEvenE | |
SingleEvenE e a | |
DeepEvenE !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a) a |
Eq2 TwoFingerEvenE Source # | |
Show2 TwoFingerEvenE Source # | |
Bifunctor TwoFingerEvenE Source # | |
Bitraversable TwoFingerEvenE Source # | |
Bifoldable TwoFingerEvenE Source # | |
Functor (TwoFingerEvenE e) Source # | |
Foldable (TwoFingerEvenE e) Source # | |
Traversable (TwoFingerEvenE e) Source # | |
Eq e => Eq1 (TwoFingerEvenE e) Source # | |
Show e => Show1 (TwoFingerEvenE e) Source # | |
Plus (TwoFingerEvenE e) Source # | |
Alt (TwoFingerEvenE e) Source # | |
(Eq e, Eq a) => Eq (TwoFingerEvenE e a) Source # | |
(Show e, Show a) => Show (TwoFingerEvenE e a) Source # | |
Generic (TwoFingerEvenE e a) Source # | |
Semigroup (TwoFingerEvenE e a) Source # | \(AnyEvenE a) (AnyEvenE b) (AnyEvenE c) -> (a <> b) <> c == a <> (b <> c) |
Monoid (TwoFingerEvenE e a) Source # | \(AnyEvenE a) -> a == a <> mempty \(AnyEvenE a) -> a == mempty <> a |
(NFData e, NFData a) => NFData (TwoFingerEvenE e a) Source # | |
type Rep (TwoFingerEvenE e a) Source # | |
data TwoFingerEvenA e a Source #
Isomorphic to (a, e)*
EmptyEvenA | |
SingleEvenA a e | |
DeepEvenA a !(Digit e a) (TwoFingerOddA (Node e a) a) !(Digit e a) |
Eq2 TwoFingerEvenA Source # | |
Show2 TwoFingerEvenA Source # | |
Bifunctor TwoFingerEvenA Source # | |
Bitraversable TwoFingerEvenA Source # | |
Bifoldable TwoFingerEvenA Source # | |
Functor (TwoFingerEvenA e) Source # | |
Foldable (TwoFingerEvenA e) Source # | |
Traversable (TwoFingerEvenA e) Source # | |
Eq e => Eq1 (TwoFingerEvenA e) Source # | |
Show e => Show1 (TwoFingerEvenA e) Source # | |
Plus (TwoFingerEvenA e) Source # | |
Alt (TwoFingerEvenA e) Source # | |
(Eq e, Eq a) => Eq (TwoFingerEvenA e a) Source # | |
(Show e, Show a) => Show (TwoFingerEvenA e a) Source # | |
Generic (TwoFingerEvenA e a) Source # | |
Semigroup (TwoFingerEvenA e a) Source # | \(AnyEvenA a) (AnyEvenA b) (AnyEvenA c) -> (a <> b) <> c == a <> (b <> c) |
Monoid (TwoFingerEvenA e a) Source # | \(AnyEvenA a) -> a == a <> mempty \(AnyEvenA a) -> a == mempty <> a |
(NFData e, NFData a) => NFData (TwoFingerEvenA e a) Source # | |
type Rep (TwoFingerEvenA e a) Source # | |
Digit operations.
digitToTree :: Digit e a -> TwoFingerOddE e a Source #
Node operations.
nodeToDigit :: Node e a -> Digit e a Source #
Tree rotations
rotl :: TwoFingerOddA (Node e a) a -> Digit e a -> TwoFingerEvenA e a Source #
rotr :: Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerEvenE e a Source #
(Un)conses/snocs for TwoFingerOddA.
consOddA :: a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
snocOddA :: TwoFingerOddA e a -> e -> a -> TwoFingerOddA e a Source #
unconsOddA :: TwoFingerOddA e a -> Either a ((a, e), TwoFingerOddA e a) Source #
unsnocOddA :: TwoFingerOddA e a -> Either a (TwoFingerOddA e a, (e, a)) Source #
halfconsOddA :: e -> TwoFingerOddA e a -> TwoFingerEvenE e a Source #
\(O(\log n)\) worst case. Inverse: halfunconsEvenE
\e (AnyOddA as) -> halfunconsEvenE (halfconsOddA e as) == Just (e, as)
halfsnocOddA :: TwoFingerOddA e a -> e -> TwoFingerEvenA e a Source #
\(O(\log n)\) worst case. Inverse: halfunsnocEvenA
\(AnyOddA as) e -> halfunsnocEvenA (halfsnocOddA as e) == Just (as, e)
halfunconsOddA :: TwoFingerOddA e a -> (a, TwoFingerEvenE e a) Source #
\(O(1)\) worst case. Inverse: halfconsEvenE
\(AnyOddA as) -> as == uncurry halfconsEvenE (halfunconsOddA as)
halfunsnocOddA :: TwoFingerOddA e a -> (TwoFingerEvenA e a, a) Source #
\(O(1)\) worst case. Inverse: halfsnocOddA
\(AnyOddA as) -> as == uncurry halfsnocEvenA (halfunsnocOddA as)
(Un)conses/snocs for TwoFingerOddE.
consOddE :: e -> a -> TwoFingerOddE e a -> TwoFingerOddE e a Source #
snocOddE :: TwoFingerOddE e a -> a -> e -> TwoFingerOddE e a Source #
unconsOddE :: TwoFingerOddE e a -> Either e ((e, a), TwoFingerOddE e a) Source #
unsnocOddE :: TwoFingerOddE e a -> Either e (TwoFingerOddE e a, (a, e)) Source #
halfconsOddE :: a -> TwoFingerOddE e a -> TwoFingerEvenA e a Source #
\(O(1)\) worst case. Inverse: halfunconsEvenA
\a (AnyOddE as) -> halfunconsEvenA (halfconsOddE a as) == Just (a, as)
halfsnocOddE :: TwoFingerOddE e a -> a -> TwoFingerEvenE e a Source #
\(O(1)\) worst case. Inverse: halfunsnocEvenE
\(AnyOddE as) a -> halfunsnocEvenE (halfsnocOddE as a) == Just (as, a)
halfunconsOddE :: TwoFingerOddE e a -> (e, TwoFingerEvenA e a) Source #
\(O(\log n)\) worst case. Inverse: halfconsEvenA
\(AnyOddE as) -> as == uncurry halfconsEvenA (halfunconsOddE as)
halfunsnocOddE :: TwoFingerOddE e a -> (TwoFingerEvenE e a, e) Source #
\(O(\log n)\) worst case. Inverse: halfsnocEvenE
\(AnyOddE as) -> as == uncurry halfsnocEvenE (halfunsnocOddE as)
(Un)conses/snocs for TwoFingerEvenE.
consEvenE :: e -> a -> TwoFingerEvenE e a -> TwoFingerEvenE e a Source #
snocEvenE :: TwoFingerEvenE e a -> e -> a -> TwoFingerEvenE e a Source #
unconsEvenE :: TwoFingerEvenE e a -> Maybe ((e, a), TwoFingerEvenE e a) Source #
unsnocEvenE :: TwoFingerEvenE e a -> Maybe (TwoFingerEvenE e a, (e, a)) Source #
halfconsEvenE :: a -> TwoFingerEvenE e a -> TwoFingerOddA e a Source #
\(O(1)\) worst case. Inverse: halfunconsOddA
\a (AnyEvenE as) -> halfunconsOddA (halfconsEvenE a as) == (a, as)
halfsnocEvenE :: TwoFingerEvenE e a -> e -> TwoFingerOddE e a Source #
\(O(\log n)\) worst case. Inverse: halfunsnocOddE
.
\(AnyEvenE as) e -> halfunsnocOddE (halfsnocEvenE as e) == (as, e)
halfunconsEvenE :: TwoFingerEvenE e a -> Maybe (e, TwoFingerOddA e a) Source #
\(O(\log n)\) worst case. Inverse: halfconsOddA
.
\(AnyEvenE as) -> as == maybe mempty (uncurry halfconsOddA) (halfunconsEvenE as)
halfunsnocEvenE :: TwoFingerEvenE e a -> Maybe (TwoFingerOddE e a, a) Source #
\(O(1)\) worst case. Inverse: halfsnocOddE
.
\(AnyEvenE as) -> as == maybe mempty (uncurry halfsnocOddE) (halfunsnocEvenE as)
(Un)conses/snocs for TwoFingerEvenA.
consEvenA :: a -> e -> TwoFingerEvenA e a -> TwoFingerEvenA e a Source #
snocEvenA :: TwoFingerEvenA e a -> a -> e -> TwoFingerEvenA e a Source #
unconsEvenA :: TwoFingerEvenA e a -> Maybe ((a, e), TwoFingerEvenA e a) Source #
unsnocEvenA :: TwoFingerEvenA e a -> Maybe (TwoFingerEvenA e a, (a, e)) Source #
halfconsEvenA :: e -> TwoFingerEvenA e a -> TwoFingerOddE e a Source #
\(O(\log n)\) worst case. Inverse: halfunconsOddE
.
\e (AnyEvenA as) -> halfunconsOddE (halfconsEvenA e as) == (e, as)
halfsnocEvenA :: TwoFingerEvenA e a -> a -> TwoFingerOddA e a Source #
\(O(1)\) worst case. Inverse: halfunsnocOddA
.
\(AnyEvenA as) a -> halfunsnocOddA (halfsnocEvenA as a) == (as, a)
halfunconsEvenA :: TwoFingerEvenA e a -> Maybe (a, TwoFingerOddE e a) Source #
\(O(1)\) worst case. Inverse: halfconsOddE
.
\(AnyEvenA as) -> as == maybe mempty (uncurry halfconsOddE) (halfunconsEvenA as)
halfunsnocEvenA :: TwoFingerEvenA e a -> Maybe (TwoFingerOddA e a, e) Source #
\(O(\log n)\) worst case. Inverse: halfsnocOddA
.
\(AnyEvenA as) -> as == maybe mempty (uncurry halfsnocOddA) (halfunsnocEvenA as)
Monad and Applicative instances, and related operations
joinOddA :: TwoFingerOddA (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerOddA e a Source #
joinOddE :: TwoFingerOddE (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerOddE e a Source #
joinEvenA :: TwoFingerEvenA (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerEvenA e a Source #
joinEvenE :: TwoFingerEvenE (TwoFingerOddE e a) (TwoFingerOddA e a) -> TwoFingerEvenE e a Source #
Construction and deconstruction of TwoFingerOddA.
singletonOddA :: a -> TwoFingerOddA e a Source #
unitOddA :: (Monoid a, Semigroup a) => e -> TwoFingerOddA e a Source #
Surrounds the argument with mempty
.
>>>
unitOddA 3 :: TwoFingerOddA Int String
consOddA "" 3 (singletonOddA "")
onlyOddA :: TwoFingerOddA e a -> Maybe a Source #
>>>
onlyOddA (singletonOddA "Hello!")
Just "Hello!">>>
onlyOddA (consOddA True 3 $ singletonOddA False)
Nothing
interleavingOddA :: e -> NonEmpty a -> TwoFingerOddA e a Source #
>>>
interleavingOddA "sep" (3 :| [4, 5])
consOddA 3 "sep" (consOddA 4 "sep" (singletonOddA 5))
Construction of TwoFingerOddE
singletonOddE :: e -> TwoFingerOddE e a Source #
Concatenation of TwoFingerOddA.
appendOddA0 :: Semigroup a => TwoFingerOddA e a -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
addDigits0 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a Source #
appendOddA1 :: TwoFingerOddA e a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
addDigits1 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a Source #
appendOddA2 :: TwoFingerOddA e a -> e -> a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
addDigits2 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a Source #
appendOddA3 :: TwoFingerOddA e a -> e -> a -> e -> a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
addDigits3 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> e -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a Source #
appendOddA4 :: TwoFingerOddA e a -> e -> a -> e -> a -> e -> a -> e -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
addDigits4 :: TwoFingerOddA (Node e a) a -> Digit e a -> a -> e -> a -> e -> a -> e -> a -> e -> a -> Digit e a -> TwoFingerOddA (Node e a) a -> TwoFingerOddA (Node e a) a Source #
Concatenation of TwoFingerEvenE.
appendEvenE :: TwoFingerEvenE e a -> TwoFingerEvenE e a -> TwoFingerEvenE e a Source #
Concatenation of TwoFingerEvenA.
appendEvenA :: TwoFingerEvenA e a -> TwoFingerEvenA e a -> TwoFingerEvenA e a Source #
Monoid actions
appendOddAEvenE :: TwoFingerOddA e a -> TwoFingerEvenE e a -> TwoFingerOddA e a Source #
\(AnyOddA a) -> a == appendOddAEvenE a mempty
appendEvenAOddA :: TwoFingerEvenA e a -> TwoFingerOddA e a -> TwoFingerOddA e a Source #
\(AnyOddA a) -> a == appendEvenAOddA mempty a
appendOddAOddE :: TwoFingerOddA e a -> TwoFingerOddE e a -> TwoFingerEvenA e a Source #
appendOddEOddA :: TwoFingerOddE e a -> TwoFingerOddA e a -> TwoFingerEvenE e a Source #
appendOddEEvenA :: TwoFingerOddE e a -> TwoFingerEvenA e a -> TwoFingerOddE e a Source #
\(AnyOddE a) -> a == appendOddEEvenA a mempty
appendEvenEOddE :: TwoFingerEvenE e a -> TwoFingerOddE e a -> TwoFingerOddE e a Source #
\(AnyOddE a) -> a == appendEvenEOddE mempty a
QuickCheck stuff.
genOddA :: Gen e -> Gen a -> Int -> Gen (TwoFingerOddA e a) Source #
The Int
parameter is expontential size: for a value \(n\), the generated tree will have (slightly more than) \(2^n\) to \(3^n\) elements.
shrinkOddA :: TwoFingerOddA e a -> [TwoFingerOddA e a] Source #
shrinkOddE :: TwoFingerOddE e a -> [TwoFingerOddE e a] Source #
shrinkEvenA :: TwoFingerEvenA e a -> [TwoFingerEvenA e a] Source #
shrinkEvenE :: TwoFingerEvenE e a -> [TwoFingerEvenE e a] Source #
AnyOddA | |
|
AnyOddE | |
|
Aligning/zipping.
alignLeftOddAOddA :: TwoFingerOddA e a -> TwoFingerOddA e' a' -> (TwoFingerOddA (e, e') (a, a'), Either (TwoFingerEvenE e a) (TwoFingerEvenE e' a')) Source #
Align two TwoFingerOddA
sequences elementwise, and return the excess remainder.
>>>
alignLeftOddAOddA (consOddA 'a' 1 $ consOddA 'b' 2 $ singletonOddA 'c') (consOddA "foo" 10 $ singletonOddA "bar")
(consOddA ('a',"foo") (1,10) (singletonOddA ('b',"bar")),Left (consEvenE 2 'c' mempty))
>>>
alignLeftOddAOddA (consOddA 'a' 1 $ singletonOddA 'b') (consOddA "foo" 10 $ consOddA "bar" 20 $ singletonOddA "baz")
(consOddA ('a',"foo") (1,10) (singletonOddA ('b',"bar")),Right (consEvenE 20 "baz" mempty))
\(AnyOddA as) (AnyOddA bs) -> let { (aligned, rest) = alignLeftOddAOddA as bs ; as' = appendOddAEvenE (bimap fst fst aligned) (either id (const mempty) rest) ; bs' = appendOddAEvenE (bimap snd snd aligned) (either (const mempty) id rest) } in as == as' && bs == bs'
alignLeftOddAEvenA :: TwoFingerOddA e a -> TwoFingerEvenA e' a' -> Either (TwoFingerEvenA (e, e') (a, a'), TwoFingerOddA e a) (TwoFingerOddA (e, e') (a, a'), TwoFingerOddE e' a') Source #
>>>
alignLeftOddAEvenA (consOddA 'a' 1 $ consOddA 'b' 2 $ singletonOddA 'c') (consEvenA "foo" 10 mempty)
Left (consEvenA ('a',"foo") (1,10) mempty,consOddA 'b' 2 (singletonOddA 'c'))
>>>
alignLeftOddAEvenA (consOddA 'a' 1 $ singletonOddA 'b') (consEvenA "foo" 10 $ consEvenA "bar" 20 $ consEvenA "baz" 30 mempty)
Right (consOddA ('a',"foo") (1,10) (singletonOddA ('b',"bar")),consOddE 20 "baz" (singletonOddE 30))
\(AnyOddA as) (AnyEvenA bs) -> let { (as', bs') = case alignLeftOddAEvenA as bs of { Left (aligned, rest) -> (appendEvenAOddA (bimap fst fst aligned) rest, bimap snd snd aligned) ; Right (aligned, rest) -> (bimap fst fst aligned, appendOddAOddE (bimap snd snd aligned) rest) } } in as == as' && bs == bs'
alignLeftEvenAEvenA :: TwoFingerEvenA e a -> TwoFingerEvenA e' a' -> (TwoFingerEvenA (e, e') (a, a'), Either (TwoFingerEvenA e a) (TwoFingerEvenA e' a')) Source #
alignLeftOddEOddE :: TwoFingerOddE e a -> TwoFingerOddE e' a' -> (TwoFingerOddE (e, e') (a, a'), Either (TwoFingerEvenA e a) (TwoFingerEvenA e' a')) Source #
>>>
alignLeftOddEOddE (consOddE 'a' 1 $ consOddE 'b' 2 $ singletonOddE 'c') (consOddE "foo" 10 $ singletonOddE "bar")
(consOddE ('a',"foo") (1,10) (singletonOddE ('b',"bar")),Left (consEvenA 2 'c' mempty))
>>>
alignLeftOddEOddE (consOddE 'a' 1 $ singletonOddE 'b') (consOddE "foo" 10 $ consOddE "bar" 20 $ singletonOddE "baz")
(consOddE ('a',"foo") (1,10) (singletonOddE ('b',"bar")),Right (consEvenA 20 "baz" mempty))
\(AnyOddE as) (AnyOddE bs) -> let { (aligned, rest) = alignLeftOddEOddE as bs ; as' = appendOddEEvenA (bimap fst fst aligned) (either id (const mempty) rest) ; bs' = appendOddEEvenA (bimap snd snd aligned) (either (const mempty) id rest) } in as == as' && bs == bs'
alignLeftOddEEvenE :: TwoFingerOddE e a -> TwoFingerEvenE e' a' -> Either (TwoFingerEvenE (e, e') (a, a'), TwoFingerOddE e a) (TwoFingerOddE (e, e') (a, a'), TwoFingerOddA e' a') Source #
\(AnyOddE as) (AnyEvenE bs) -> let { (as', bs') = case alignLeftOddEEvenE as bs of { Left (aligned, rest) -> (appendEvenEOddE (bimap fst fst aligned) rest, bimap snd snd aligned) ; Right (aligned, rest) -> (bimap fst fst aligned, appendOddEOddA (bimap snd snd aligned) rest) } } in as == as' && bs == bs'
alignLeftEvenEEvenE :: TwoFingerEvenE e a -> TwoFingerEvenE e' a' -> (TwoFingerEvenE (e, e') (a, a'), Either (TwoFingerEvenE e a) (TwoFingerEvenE e' a')) Source #
Creating infinite sequences.
takeNodeLeft :: (Stream a -> es -> (e, Stream a, es)) -> Stream a -> es -> (Node e a, Stream a, es) Source #
takeNodeRight :: (es -> Stream a -> (e, es, Stream a)) -> es -> Stream a -> (Node e a, es, Stream a) Source #
infiniteOddA' :: (Stream a -> Stream e -> (Node e' a, Stream a, Stream e)) -> (Stream e -> Stream a -> (Node e' a, Stream e, Stream a)) -> Stream a -> Stream e -> Stream e -> Stream a -> TwoFingerOddA e' a Source #
repeatOddA :: a -> e -> TwoFingerOddA e a Source #
Infinitely repeat the given a
and e
.
\(AnyOddA as) -> as == bimap (uncurry ($)) (uncurry ($)) (fst $ alignLeftOddAOddA (repeatOddA id id) as)
\(AnyEvenA as) -> either ((as ==) . bimap (uncurry ($)) (uncurry ($)) . fst) (const False) (alignLeftOddAEvenA (repeatOddA id id) as)
infiniteOddA :: Stream a -> Stream e -> Stream e -> Stream a -> TwoFingerOddA e a Source #
From streams of leftward a
, leftward e
, rightward e
and
rightward a
, build an infinite TwoFingerOddA
.
>>>
let infinite = infiniteOddA (Stream.iterate (+ 1) 0) (Stream.iterate (+ 1) 10) (Stream.iterate (+ 1) 20) (Stream.iterate (+ 1) 30)
>>>
take 5 $ unfoldr (hush . unconsOddA) infinite
[(0,10),(1,11),(2,12),(3,13),(4,14)]>>>
take 5 $ unfoldr (fmap swap . hush . unsnocOddA) infinite
[(20,30),(21,31),(22,32),(23,33),(24,34)]
repeatOddE :: e -> a -> TwoFingerOddE e a Source #
Infinitely repeat the given a
and e
.
\(AnyOddE as) -> as == bimap (uncurry ($)) (uncurry ($)) (fst $ alignLeftOddEOddE (repeatOddE id id) as)
\(AnyEvenE as) -> either ((==) as . bimap (uncurry ($)) (uncurry ($)) . fst) (const False) $ alignLeftOddEEvenE (repeatOddE id id) as
infiniteOddE :: Stream e -> Stream a -> Stream a -> Stream e -> TwoFingerOddE e a Source #
>>>
let infinite = infiniteOddE (Stream.iterate (+ 1) 0) (Stream.iterate (+ 1) 10) (Stream.iterate (+ 1) 20) (Stream.iterate (+ 1) 30)
>>>
take 5 $ unfoldr (hush . unconsOddE) infinite
[(0,10),(1,11),(2,12),(3,13),(4,14)]>>>
take 5 $ unfoldr (fmap swap . hush . unsnocOddE) infinite
[(20,30),(21,31),(22,32),(23,33),(24,34)]
repeatEvenA :: a -> e -> TwoFingerEvenA e a Source #
Infinitely repeat the given a
and e
.
\(AnyEvenA as) -> as == bimap (uncurry ($)) (uncurry ($)) (fst $ alignLeftEvenAEvenA (repeatEvenA id id) as)
\(AnyOddA as) -> either (const False) ((==) as . bimap (uncurry $ flip ($)) (uncurry $ flip ($)) . fst) $ alignLeftOddAEvenA as (repeatEvenA id id)
infiniteEvenA :: Stream a -> Stream e -> Stream a -> Stream e -> TwoFingerEvenA e a Source #
>>>
let infinite = infiniteEvenA (Stream.iterate (+ 1) 0) (Stream.iterate (+ 1) 10) (Stream.iterate (+ 1) 20) (Stream.iterate (+ 1) 30)
>>>
take 5 $ unfoldr unconsEvenA infinite
[(0,10),(1,11),(2,12),(3,13),(4,14)]>>>
take 5 $ unfoldr (fmap swap . unsnocEvenA) infinite
[(20,30),(21,31),(22,32),(23,33),(24,34)]
repeatEvenE :: e -> a -> TwoFingerEvenE e a Source #
\(AnyEvenE as) -> as == bimap (uncurry ($)) (uncurry ($)) (fst $ alignLeftEvenEEvenE (repeatEvenE id id) as)
\(AnyOddE as) -> either (const False) ((==) as . bimap (uncurry $ flip ($)) (uncurry $ flip ($)) . fst) $ alignLeftOddEEvenE as (repeatEvenE id id)
infiniteEvenE :: Stream e -> Stream a -> Stream e -> Stream a -> TwoFingerEvenE e a Source #
>>>
let infinite = infiniteEvenE (Stream.iterate (+ 1) 0) (Stream.iterate (+ 1) 10) (Stream.iterate (+ 1) 20) (Stream.iterate (+ 1) 30)
>>>
take 5 $ unfoldr unconsEvenE infinite
[(0,10),(1,11),(2,12),(3,13),(4,14)]>>>
take 5 $ unfoldr (fmap swap . unsnocEvenE) infinite
[(20,30),(21,31),(22,32),(23,33),(24,34)]