h$91      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Safe 567?ralSize of a tree.ral Direction in .ral is a product of two f-. This way we can form a perfect binary tree.ralA  is isomorphic to Identity, but we reimplement it here to have domain specific type. The short constructor name is a bonus.Safe Safe 0567?,ral8Non-empty random access list, underlying representation.The structure doesn't need to be hidden, as polymorphic recursion of s starting from  keeps the   values well-formed. ralNon-empty random access list.ralSingle element  .ral for non-empty rals.ral fromNonEmpty ('a' :| ['b'..'f'])fromNonEmpty ('a' :| "bcdef")/explicitShow (fromNonEmpty ('a' :| ['b'..'f']))"NE (Cons0 (Cons1 (Nd (Lf 'a') (Lf 'b')) (Last (Nd (Nd (Lf 'c') (Lf 'd')) (Nd (Lf 'e') (Lf 'f'))))))"ral List index.$fromNonEmpty ('a' :| ['b'..'f']) ! 0'a'$fromNonEmpty ('a' :| ['b'..'f']) ! 5'f'$fromNonEmpty ('a' :| ['b'..'f']) ! 61*** Exception: array index out of range: NERAList...ralsafe list index.%fromNonEmpty ('a' :| ['b'..'f']) !? 0Just 'a'%fromNonEmpty ('a' :| ['b'..'f']) !? 5Just 'f'%fromNonEmpty ('a' :| ['b'..'f']) !? 6NothingralFirst value, head of the list.'head $ fromNonEmpty $ 'a' :| ['b'..'f']'a'ralLast value of the list(last $ fromNonEmpty $ 'a' :| ['b'..'f']'f'ral import Data.Semigroup (Min (..))9ifoldMap1 (\_ x -> Min x) $ fromNonEmpty $ 5 :| [3,1,2,4]Min {getMin = 1}?ifoldMap1 (\i x -> Min (i + x)) $ fromNonEmpty $ 5 :| [3,1,2,4]Min {getMin = 3}ral.map toUpper (fromNonEmpty ('a' :| ['b'..'f']))fromNonEmpty ('A' :| "BCDEF")ral+imap (,) (fromNonEmpty ('a' :| ['b'..'f']))fromNonEmpty ((0,'a') :| [(1,'b'),(2,'c'),(3,'d'),(4,'e'),(5,'f')])"ralAdjust a value in the list.0adjust 3 toUpper $ fromNonEmpty $ 'a' :| "bcdef"fromNonEmpty ('a' :| "bcDef");If index is out of bounds, the list is returned unmodified.1adjust 10 toUpper $ fromNonEmpty $ 'a' :| "bcdef"fromNonEmpty ('a' :| "bcdef")3adjust (-1) toUpper $ fromNonEmpty $ 'a' :| "bcdef"fromNonEmpty ('a' :| "bcdef")ralralralral8fromNonEmpty ('a' :| "bc") <> fromNonEmpty ('x' :| "yz")fromNonEmpty ('a' :| "bcxyz")ral-I.length $ fromNonEmpty $ 'x' :| ['a' .. 'z']27  !" Safe 0567?#ralRandom access list.(ralEmpty #.empty :: RAList Int fromList [])ralSingle element #.*ral* for non-empty rals.,ralfromList ['a' .. 'f']fromList "abcdef"$explicitShow $ fromList ['a' .. 'f']"NonEmpty (NE (Cons0 (Cons1 (Nd (Lf 'a') (Lf 'b')) (Last (Nd (Nd (Lf 'c') (Lf 'd')) (Nd (Lf 'e') (Lf 'f')))))))".ralsafe list index.fromList ['a'..'f'] !? 0Just 'a'fromList ['a'..'f'] !? 5Just 'f'fromList ['a'..'f'] !? 6Nothing2ral!map toUpper (fromList ['a'..'f'])fromList "ABCDEF"3ral imap (,) $ fromList ['a' .. 'f']:fromList [(0,'a'),(1,'b'),(2,'c'),(3,'d'),(4,'e'),(5,'f')]5ralAdjust a value in the list.#adjust 3 toUpper $ fromList "bcdef"fromList "bcdEf";If index is out of bounds, the list is returned unmodified.$adjust 10 toUpper $ fromList "bcdef"fromList "bcdef"&adjust (-1) toUpper $ fromList "bcdef"fromList "bcdef"ralralralral fromList "abc" <> fromList "xyz"fromList "abcxyz"ral"I.length $ fromList $ ['a' .. 'z']26#%$&'()*+,-./012345Safe6ral$Tail of non-empty list can be empty.$tail $ fromNonEmpty $ 'a' :| "bcdef"fromList "bcdef"7ral&uncons $ fromNonEmpty $ 'a' :| "bcdef"('a',fromList "bcdef")  !"67  76" !SafeR8raluncons $ fromList []Nothinguncons $ fromList "abcdef"Just ('a',fromList "bcdef")#%$&'()*+,-./0123458#%$&'()*-.8/0+,15234Safe'(/23>09ral(Perfectly balanced binary tree of depth n, with 2 ^ n elements.<ral9$ of zero depth, with single element.singleton True Leaf True=ralConvert 9 to list.toList $ Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'c') (Leaf 'd'))"abcd">ral Indexing.BralReverse 9.let t = Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'c') (Leaf 'd')) reverse t>Node (Node (Leaf 'd') (Leaf 'c')) (Node (Leaf 'b') (Leaf 'a'))Gral,foldr (:) [] $ Node (Leaf True) (Leaf False) [True,False]Kral3foldl (flip (:)) [] $ Node (Leaf True) (Leaf False) [False,True]MralNral-length (universe :: Tree N.Nat3 (Wrd N.Nat3))8Oral Non-strict O.Pral Non-strict P.Qral'map not $ Node (Leaf True) (Leaf False)Node (Leaf False) (Leaf True)Rral(imap (,) $ Node (Leaf True) (Leaf False))Node (Leaf (0b0,True)) (Leaf (0b1,False))WralXralZip two Vecs with a function.YralZip two 99s. with a function that also takes the elements' indices.ZralRepeat a value.repeat 'x' :: Tree N.Nat2 Char>Node (Node (Leaf 'x') (Leaf 'x')) (Node (Leaf 'x') (Leaf 'x'))[ralGet all Vec n  indices in 9 n.$universe :: Tree N.Nat2 (Wrd N.Nat2)Node (Node (Leaf 0b00) (Leaf 0b01)) (Node (Leaf 0b10) (Leaf 0b11))krallralmral%9;:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]%9;:<=B>?@ACEDFGHIJKLNMOPQRSTUVWXYZ[\]Safe'(/3>&wralt with exactly one element.singleton True Leaf TruexralConvert t to list.toList $ Node (Node (Leaf 'f') (Leaf 'o')) (Node (Leaf 'o') (Leaf 'd'))"food"yral Indexing.let t = Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'c') (Leaf 'd'))t ! W1 (W0 WE)'c'zralTabulating, inverse of y.'tabulate id :: Tree N.Nat2 (Wrd N.Nat2)Node (Node (Leaf 0b00) (Leaf 0b01)) (Node (Leaf 0b10) (Leaf 0b11))}ralReverse t.let t = Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'c') (Leaf 'd')) reverse t>Node (Node (Leaf 'd') (Leaf 'c')) (Node (Leaf 'b') (Leaf 'a'))~ral'map not $ Node (Leaf True) (Leaf False)Node (Leaf False) (Leaf True)rallet t = Node (Node (Leaf 'a') (Leaf 'b')) (Node (Leaf 'c') (Leaf 'd')) imap (,) tNode (Node (Leaf (0b00,'a')) (Leaf (0b01,'b'))) (Node (Leaf (0b10,'c')) (Leaf (0b11,'d')))ral&Apply an action to every element of a t , yielding a t of results.ral&Apply an action to every element of a t and its index, yielding a t of results.ralApply an action to non-empty t , yielding a t of results.ral&Apply an action to every element of a t% and its index, ignoring the results.ralSee .ralSee .ralSee   .ral"There is no type-class for this :(ral Right fold.ralRight fold with an index.ral Left fold.ralLeft fold with an index.ralYield the length of a t. O(n)ralTest whether a t is empty. It never is. O(1)ral Non-strict .ral Non-strict .ralZip two ts with a function.ralZip two t9s. with a function that also takes the elements' indices.ral Repeat valuerepeat 'x' :: Tree N.Nat2 Char>Node (Node (Leaf 'x') (Leaf 'x')) (Node (Leaf 'x') (Leaf 'x'))ralGet all  n in a t n.$universe :: Tree N.Nat2 (Wrd N.Nat2)Node (Node (Leaf 0b00) (Leaf 0b01)) (Node (Leaf 0b10) (Leaf 0b11))ral Ensure spine.If we have an undefined t,'let v = error "err" :: Tree N.Nat2 CharAnd insert data into it later:let setHead :: a -> Tree N.Nat2 a -> Tree N.Nat2 a; setHead x (Node (Node _ u) v) = Node (Node (Leaf x) u) v#Then without a spine, it will fail:leftmost $ setHead 'x' v*** Exception: err...But with the spine, it won't:&leftmost $ setHead 'x' $ ensureSpine v'x'ralralral&tuvwxyz{|}~&tuvwx}yz{|~  Trustworthy'=Safe'(/23>?( ral7Non-empty random access list, undelying representation.ralNon-empty random access list.ral for non-empty rals.ral for non-empty rals.ralZip two s with a function.ralZip two #s with a function which also takes  index.ralralralralralralSafe'(/23>?1ral#Length indexed random access lists.ralCons an element in front of .+reifyList "xyz" (print . toList . cons 'a')"axyz"ral Variant of  which computes the  dictionary at the same time.ral!The first element of a non-empty . reifyNonEmpty ('x' :| "yz") head'x'ral The last element of a non-empty . reifyNonEmpty ('x' :| "yz") last'z'ralConvert a list [a] to  b a . Returns  if lengths don't match.+fromList "foo" :: Maybe (RAVec B.Bin3 Char)Just (NonEmpty (NE (Cons1 (Leaf 'f') (Last (Node (Leaf 'o') (Leaf 'o')))))),fromList "quux" :: Maybe (RAVec B.Bin3 Char)Nothing*fromList "xy" :: Maybe (RAVec B.Bin3 Char)NothingralreifyList "foo" printNonEmpty (NE (Cons1 (Leaf 'f') (Last (Node (Leaf 'o') (Leaf 'o')))))reifyList "xyzzy" toList"xyzzy"ral Indexing.8let ral :: RAVec B.Bin4 Char; Just ral = fromList "abcd"ral ! minBound'a'ral ! maxBound'd' ral ! pop top'b'ralZip two s with a function.ralZip two #s with a function which also takes  index.ralRepeat a value.repeat 'x' :: RAVec B.Bin5 CharNonEmpty (NE (Cons1 (Leaf 'x') (Cons0 (Last (Node (Node (Leaf 'x') (Leaf 'x')) (Node (Leaf 'x') (Leaf 'x')))))))ral%universe :: RAVec B.Bin2 (Pos B.Bin2)5NonEmpty (NE (Cons0 (Last (Node (Leaf 0) (Leaf 1)))))-let u = universe :: RAVec B.Bin3 (Pos B.Bin3)u>NonEmpty (NE (Cons1 (Leaf 0) (Last (Node (Leaf 1) (Leaf 2))))))P.explicitShow $ u ! Pos (PosP (Here WE))"Pos (PosP (Here WE))".let u' = universe :: RAVec B.Bin5 (Pos B.Bin5)toList u' == sort (toList u')Trueralralral##            ! " # $ % & ' ( ) * + , - . / 0 1 2 3   4   5 6 ! " % & ) , - . 078895!:;<=>)'*?@(+AB&%CD,-E.F/GHIJKLMNOPQRSTUVWXYZ[\]^_`abc95!:;<=,-E.F/G>')*?@(+AB%&CDHIJKdLMNOPQReSTUV[\]^YZ_`cbaXWfghijkl#m$n5opqr!s:t>u)v'w*x?(+yz{@|,}-~E.F/HIJKLM234j#$56q!:>)'*?@&,-E.F/HIJKLM#$0.@F(*+/      5     ral-0.2-Hd6DT9G5YDp6Jfpmb819QQData.RAList.TreeData.RAList.NonEmpty Data.RAListData.RAVec.TreeData.RAVec.Tree.DFData.RAVec.NonEmpty Data.RAVecData.RAList.Tree.InternalData.RAList.NonEmpty.InternalData.RAList.InternalIFoldableWithIndexTrustworthyCompatDirLRNodeNdLeafLf NERAList'LastCons0Cons1NERAListNE explicitShowexplicitShowsPrec singletoncons toNonEmpty fromNonEmpty!!?headlastlengthnullfoldMap1 foldr1MapifoldMap ifoldMap1 ifoldr1Mapmapimap itraverse itraverse1adjustRAListEmptyNonEmptyemptytoListfromListtailunconsTreetabulateleftmost rightmostreversefoldMapfoldrifoldrfoldlifoldlsumproducttraverse traverse1 itraverse_zipWithizipWithrepeatuniverse liftArbitrary liftShrink$fFunctionTree$fCoArbitraryTree$fArbitraryTree$fArbitrary1Tree $fApplyTree$fSemigroupTree$fRepresentableTree$fDistributiveTree$fApplicativeTree$fHashableTree $fNFDataTree$fTraversable1Tree$fFoldable1Tree$fTraversableWithIndexWrdTree$fFoldableWithIndexWrdTree$fFunctorWithIndexWrdTree$fTraversableTree$fFoldableTree $fFunctorTree $fShowTree $fOrdTree$fEqTree ensureSpine $fMonoidTreeNERAVec'NERAVec singleton'consTreewithCons withConsTree unsingletonhead'last'toList' toNonEmpty' reifyNonEmptyreifyNonEmpty'index' tabulate'foldMap' ifoldMap' foldMap1' ifoldMap1'foldr' foldr1Map' ifoldr1Map'ifoldr'map'imap' traverse' itraverse' traverse1' itraverse1'zipWith' izipWith'repeat' universe'liftArbitrary' liftShrink'$fFunctionNERAVec'$fCoArbitraryNERAVec'$fArbitrary1NERAVec'$fApplyNERAVec'$fMonoidNERAVec'$fSemigroupNERAVec'$fRepresentableNERAVec'$fDistributiveNERAVec'$fApplicativeNERAVec'$fHashableNERAVec'$fNFDataNERAVec'$fTraversable1NERAVec'$fFoldable1NERAVec'#$fTraversableWithIndexPosP'NERAVec' $fFoldableWithIndexPosP'NERAVec'$fFunctorWithIndexPosP'NERAVec'$fTraversableNERAVec'$fFoldableNERAVec'$fFunctorNERAVec' $fOrdNERAVec'$fFunctionNERAVec$fCoArbitraryNERAVec$fArbitraryNERAVec$fArbitrary1NERAVec$fApplyNERAVec$fMonoidNERAVec$fSemigroupNERAVec$fRepresentableNERAVec$fDistributiveNERAVec$fApplicativeNERAVec$fHashableNERAVec$fNFDataNERAVec$fTraversable1NERAVec$fFoldable1NERAVec!$fTraversableWithIndexPosPNERAVec$fFoldableWithIndexPosPNERAVec$fFunctorWithIndexPosPNERAVec$fTraversableNERAVec$fFoldableNERAVec$fFunctorNERAVec $fEqNERAVec $fOrdNERAVec $fShowNERAVec$fShowNERAVec' $fEqNERAVec'RAVec reifyList$fFunctionRAVec$fCoArbitraryRAVec$fArbitraryRAVec$fArbitrary1RAVec $fApplyRAVec $fMonoidRAVec$fSemigroupRAVec$fRepresentableRAVec$fDistributiveRAVec$fApplicativeRAVec$fHashableRAVec $fNFDataRAVec$fTraversable1RAVec$fFoldable1RAVec$fTraversableWithIndexPosRAVec$fFoldableWithIndexPosRAVec$fFunctorWithIndexPosRAVec$fTraversableRAVec$fFoldableRAVec$fFunctorRAVec $fOrdRAVec $fShowRAVec $fEqRAVecSizeIsTree safeIndexOffset!$fTraversableWithIndexIntNERAList$fFoldableWithIndexIntNERAList$fFunctorWithIndexIntNERAList$fSemigroupNERAList$fFoldableNERAList$fTraversableWithIndexIntRAList$fFoldableWithIndexIntRAList$fFunctorWithIndexIntRAList$fSemigroupRAList$fFoldableRAListghc-prim GHC.TypesBoolbase Data.FoldableFoldable*semigroupoids-5.3.5-4VXEKygpgR48yFJmBKDNcTData.Semigroup.Foldable.Class Foldable1 bin-0.1.1-JzdlGsuInyoIcATm54JXxWData.WrdWrdGHC.PrimcoerceData.Type.Equality:~:Refl TestEquality testEqualityData.BinP.PosPPosP' Data.Type.BinSBinI GHC.MaybeNothing Data.Bin.PosPos