h&vl      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef g h i j k l m n o p q r s t u v w x y z { | } ~                                                             $Algebra, ColAlgebra, and other stuff(c) gspia 2020-BSDgspia Safe-Inferred !01fcf-containersType-level Second. Tuples (,) and Either have Second-instances.Example%:kind! Eval (Second ((+) 1) '("a",3))9Eval (Second ((+) 1) '("a",3)) :: (TL.Symbol, TL.Natural) = '("a", 4)fcf-containersType-level First. Tuples (,) and Either have First-instances.Example$:kind! Eval (First ((+) 1) '(3,"a"))8Eval (First ((+) 1) '(3,"a")) :: (TL.Natural, TL.Symbol) = '(4, "a")fcf-containersHisto takes annotation algebra and takes a Fix-structure (from Recursion Schemes by example, Tim Williams).Examples can be found from Fcf.Data.Alg.Tree and Fcf.Data.Alg.List modules.fcf-containersHisto takes annotation algebra and takes a Fix-structure (from Recursion Schemes by example, Tim Williams).This is a helper for  as it is implemented with .fcf-containersSynthesized attributes are created in a bottom-up traversal using a catamorphism (from Recursion Schemes by example, Tim Williams).For the example, see Fcf.Data.Alg.Tree.Sizes.fcf-containersSynthesized attributes are created in a bottom-up traversal using a catamorphism (from Recursion Schemes by example, Tim Williams).,This is the algebra that is fed to the cata.fcf-containersAnnotation constructor (from Recursion Schemes by example, Tim Williams).fcf-containersStrip attribute from root (from Recursion Schemes by example, Tim Williams).fcf-containersAttribute of the root node (from Recursion Schemes by example, Tim Williams). fcf-containersAnnotated fixed-point type. A cofree comonad (from Recursion Schemes by example, Tim Williams). fcf-containersAnnotate (f r) with attribute a (from Recursion Schemes by example, Tim Williams). fcf-containersWrite a function to give a #, and feed it in together with an Check Fcf.Alg.List to see example algebras in use. There we have e.g. ListToParaFix-function.fcf-containersHylomorphism uses first ( to build a structure (unfold) and then " to process the structure (fold).Example+data NToOneCoA :: CoAlgebra (ListF Nat) Nat:{$ type instance Eval (NToOneCoA b) = If (Eval (b < 1) ) 'NilF ('ConsF b ( b TL.- 1)):}%:kind! Eval (Hylo SumAlg NToOneCoA 5),Eval (Hylo SumAlg NToOneCoA 5) :: TL.Natural= 15fcf-containers Ana can also be used to build a  structure.Example+data NToOneCoA :: CoAlgebra (ListF Nat) Nat:{$ type instance Eval (NToOneCoA b) = If (Eval (b < 1) ) 'NilF ('ConsF b ( b TL.- 1)):}:kind! Eval (Ana NToOneCoA 3)0Eval (Ana NToOneCoA 3) :: Fix (ListF TL.Natural)= 'Fix ('ConsF 3 ('Fix ('ConsF 2 ('Fix ('ConsF 1 ('Fix 'NilF))))))fcf-containersWrite the function to give a #, and feed it in together with an .Check Fcf.Alg.List to see example algebras in use. There we have e.g. ListToFix-function.fcf-containers)Commonly used name describing the method   eats.fcf-containers)Commonly used name describing the method  eats.fcf-containers)Commonly used name describing the method  eats.fcf-containersStructure that , can fold and that is a result structure of .  ListF structure working with Algebras, ColAlgebras, and other stuff(c) gspia 2020-BSDgspia Safe-Inferred !01%fcf-containers>Equal tests for list equality. We may change the name to (==).Example %:kind! Eval (Equal '[1,2,3] '[1,2,3])/Eval (Equal '[1,2,3] '[1,2,3]) :: Bool = 'True %:kind! Eval (Equal '[1,2,3] '[1,3,2])0Eval (Equal '[1,2,3] '[1,3,2]) :: Bool = 'Falsefcf-containersToList for type-level lists.Example :kind! Eval (ToList 1)'Eval (ToList 1) :: [TL.Natural] = '[1]fcf-containers1Function to form Nat lists like [1..5] or [3..10]Example :kind! Eval (MToN 1 3)-Eval (MToN 1 3) :: [TL.Natural] = '[1, 2, 3]fcf-containers/Helper to form Nat lists like [1..5] or [3..10]:kind! Eval (Unfoldr ToThree 1)fcf-containersSum a Nat-list.Example :kind! Eval (Sum '[1,2,3])&Eval (Sum '[1,2,3]) :: TL.Natural = 6fcf-containersConstruct a run (that is, a natuaral number sequence from 1 to arg).Example :kind! Eval (RunInc 8)Tim Williams, Recursion Schemes by example, example for Histo. fcf-containers>Tim Williams, Recursion Schemes by example, example for Histo.!fcf-containersTim Williams, Recursion Schemes by example, example for Para. See " -function."fcf-containers:Example from Recursion Schemes by example by Tim Williams.Example &:kind! Eval (Sliding 3 '[1,2,3,4,5,6])Eval (Sliding 3 '[1,2,3,4,5,6]) :: [[TL.Natural]] = '[ '[1, 2, 3], '[2, 3, 4], '[3, 4, 5], '[4, 5, 6], '[5, 6], '[6]]#fcf-containers1Example from recursion-package by Vanessa McHale.This removes duplicates from a list (by keeping the right-most one).Example :kind! Eval (Para DedupAlg =<< ListToParaFix '[1,1,3,2,5,1,3,2])Eval (Para DedupAlg =<< ListToParaFix '[1,1,3,2,5,1,3,2]) :: [TL.Natural] = '[5, 1, 3, 2]$fcf-containers0Form a Fix-structure that can be used with Para.Example $:kind! Eval (ListToParaFix '[1,2,3])Eval (ListToParaFix '[1,2,3]) :: Fix (ListF (TL.Natural, [TL.Natural])) = 'Fix ('ConsF '(1, '[2, 3]) ('Fix ('ConsF '(2, '[3]) ('Fix ('ConsF '(3, '[]) ('Fix 'NilF))))))%fcf-containers8Example algebra to calculate the prod of Nats in a list.Example 3:kind! Eval (Cata ProdAlg =<< ListToFix '[1,2,3,4])Eval (Cata ProdAlg =<< ListToFix '[1,2,3,4]) :: TL.Natural = 24&fcf-containers7Example algebra to calculate the sum of Nats in a list.Example 2:kind! Eval (Cata SumAlg =<< ListToFix '[1,2,3,4])?Eval (Cata SumAlg =<< ListToFix '[1,2,3,4]) :: TL.Natural = 10'fcf-containers)Example algebra to calculate list length.Example 0:kind! Eval (Cata LenAlg =<< ListToFix '[1,2,3]) 'a')Eval ('b' > 'a') :: Bool= 'True?fcf-containers!Less-than comparison for symbols.Example:kind! Eval ('a' < 'b')Eval ('a' < 'b') :: Bool= 'True@fcf-containers,Larger-than-or-equal comparison for symbols.Example:kind! Eval ('b' >= 'a')Eval ('b' >= 'a') :: Bool= 'TrueAfcf-containers*Less-than-or-equal comparison for symbols.Example:kind! Eval ('b' <= 'a')Eval ('b' <= 'a') :: Bool= 'FalseBfcf-containersCharOrd - compare two symbols and give type-level Ordering ( $ 'LT $, $ 'EQ $ or $ 'GT $ ).Example:kind! Eval (CharOrd 'a' 'b')"Eval (CharOrd 'a' 'b') :: Ordering= 'LTCfcf-containersIsDigitExample:kind! Eval (IsDigit '3')Eval (IsDigit '3') :: Bool= 'True:kind! Eval (IsDigit 'a')Eval (IsDigit 'a') :: Bool= 'FalseDfcf-containers IsSpaceDelimExample:kind! Eval (IsSpaceDelim 'a')Eval (IsSpaceDelim 'a') :: Bool= 'False:kind! Eval (IsSpaceDelim '\n') Eval (IsSpaceDelim '\n') :: Bool= 'TrueEfcf-containersIsTabExample:kind! Eval (IsTab 'a')Eval (IsTab 'a') :: Bool= 'False:kind! Eval (IsTab '\t')Eval (IsTab '\t') :: Bool= 'TrueFfcf-containers IsNewlineExample:kind! Eval (IsNewLine 'a')Eval (IsNewLine 'a') :: Bool= 'False:kind! Eval (IsNewLine '\n')Eval (IsNewLine '\n') :: Bool= 'TrueGfcf-containersIsSpaceExample:kind! Eval (IsSpace 'a')Eval (IsSpace 'a') :: Bool= 'False:kind! Eval (IsSpace ' ')Eval (IsSpace ' ') :: Bool= 'True =>?@ABCDEFG GFEDCBA@?>=List helpers / utils(c) gspia 2023-BSDgspia Safe-Inferred!0132Hfcf-containersTurn Maybe into a list.Example#:kind! Eval (MaybeToList ('Just 1)),Eval (MaybeToList ('Just 1)) :: [TL.Natural]= '[1]Ifcf-containersFoldl in terms of Foldr.Example':kind! Eval (Foldl (Fcf.-) 10 '[3,2,1]).Eval (Foldl (Fcf.-) 10 '[3,2,1]) :: TL.Natural= 4HIIH:Map (association) data-type for the type-level programming(c) gspia 2020-BSDgspia Safe-Inferred !01\Jfcf-containers PartitionExample:kind! Eval (Partition ((>=) 35) =<< FromList '[ '(5,50), '(3,30)])Eval (Partition ((>=) 35) =<< FromList '[ '(5,50), '(3,30)]) :: (MapC TL.Natural TL.Natural, MapC TL.Natural TL.Natural),= '( 'MapC '[ '(3, 30)], 'MapC '[ '(5, 50)])Kfcf-containers FilterWithKeyExample:kind! Eval (FilterWithKey (>=) =<< FromList '[ '(3,5), '(6,4)])Eval (FilterWithKey (>=) =<< FromList '[ '(3,5), '(6,4)]) :: MapC TL.Natural TL.Natural= 'MapC '[ '(6, 4)]Lfcf-containersFilterExample:kind! Eval (Filter ((>=) 35) =<< FromList '[ '(5,50), '(3,30)])Eval (Filter ((>=) 35) =<< FromList '[ '(5,50), '(3,30)]) :: MapC TL.Natural TL.Natural= 'MapC '[ '(3, 30)]Mfcf-containersToListExample8:kind! Eval (ToList =<< FromList '[ '(5,"a"), '(3,"b")])Eval (ToList =<< FromList '[ '(5,"a"), '(3,"b")]) :: [(TL.Natural, TL.Symbol)]= '[ '(5, "a"), '(3, "b")]:kind! Eval (ToList =<< Empty)#Eval (ToList =<< Empty) :: [(k, v)]= '[]Nfcf-containersAssocsExample8:kind! Eval (Assocs =<< FromList '[ '(5,"a"), '(3,"b")])Eval (Assocs =<< FromList '[ '(5,"a"), '(3,"b")]) :: [(TL.Natural, TL.Symbol)]= '[ '(5, "a"), '(3, "b")]:kind! Eval (Assocs =<< Empty)#Eval (Assocs =<< Empty) :: [(k, v)]= '[]Ofcf-containersKeysExample6:kind! Eval (Keys =<< FromList '[ '(5,"a"), '(3,"b")])?Eval (Keys =<< FromList '[ '(5,"a"), '(3,"b")]) :: [TL.Natural] = '[5, 3]:kind! Eval (Keys =<< Empty)Eval (Keys =<< Empty) :: [k]= '[]Pfcf-containersElemsExample7:kind! Eval (Elems =<< FromList '[ '(5,"a"), '(3,"b")])?Eval (Elems =<< FromList '[ '(5,"a"), '(3,"b")]) :: [TL.Symbol] = '["a", "b"]:kind! Eval (Elems =<< Empty)Eval (Elems =<< Empty) :: [v]= '[]Qfcf-containersFoldrFold the values in the map using the given right-associative binary operator, such that 'foldr f z == foldr f z . elems'.Note: the order of values in MapC is not well defined at the moment.Example:kind! Eval (Fcf.Data.MapC.Foldr (+) 0 =<< (FromList '[ '(1,1), '(2,2)]))Eval (Fcf.Data.MapC.Foldr (+) 0 =<< (FromList '[ '(1,1), '(2,2)])) :: TL.Natural= 3Rfcf-containers MapWithKeyExampleSfcf-containersMapExample:kind! Eval (Fcf.Data.MapC.Map (AppendSymbol "x") =<< FromList '[ '(5,"a"), '(3,"b")])Eval (Fcf.Data.MapC.Map (AppendSymbol "x") =<< FromList '[ '(5,"a"), '(3,"b")]) :: MapC TL.Natural TL.Symbol"= 'MapC '[ '(5, "xa"), '(3, "xb")]Tfcf-containersDisjointExample:kind! Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")])))Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")]))) :: Bool= 'False:kind! Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(2,"B"), '(7,"C")])))Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(2,"B"), '(7,"C")]))) :: Bool= 'True0:kind! Eval (Disjoint (Eval Empty) (Eval Empty))1Eval (Disjoint (Eval Empty) (Eval Empty)) :: Bool= 'TrueUfcf-containers IntersectionExample:kind! Eval (Intersection (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")])))Eval (Intersection (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")]))) :: MapC TL.Natural TL.Symbol= 'MapC '[ '(5, "b")]Vfcf-containers DifferenceExample:kind! Eval (Difference (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")])))Eval (Difference (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")]))) :: MapC TL.Natural TL.Symbol= 'MapC '[ '(3, "a")]Wfcf-containersUnionExample:kind! Eval (Union (Eval (FromList '[ '(5,"a"), '(3,"b")])) (Eval (FromList '[ '(5,"A"), '(7,"c")])) )Eval (Union (Eval (FromList '[ '(5,"a"), '(3,"b")])) (Eval (FromList '[ '(5,"A"), '(7,"c")])) ) :: MapC TL.Natural TL.Symbol+= 'MapC '[ '(7, "c"), '(5, "a"), '(3, "b")]Xfcf-containersSizeExample6:kind! Eval (Size =<< FromList '[ '(5,"a"), '(3,"b")])=Eval (Size =<< FromList '[ '(5,"a"), '(3,"b")]) :: TL.Natural= 2Yfcf-containersNullExample6:kind! Eval (Null =<< FromList '[ '(5,"a"), '(3,"b")])7Eval (Null =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'False:kind! Eval (Null =<< Empty)Eval (Null =<< Empty) :: Bool= 'TrueZfcf-containers NotMemberExample=:kind! Eval (NotMember 5 =<< FromList '[ '(5,"a"), '(3,"b")])>Eval (NotMember 5 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'False=:kind! Eval (NotMember 7 =<< FromList '[ '(5,"a"), '(3,"b")])>Eval (NotMember 7 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'True[fcf-containersMemberExample::kind! Eval (Member 5 =<< FromList '[ '(5,"a"), '(3,"b")]);Eval (Member 5 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'True::kind! Eval (Member 7 =<< FromList '[ '(5,"a"), '(3,"b")]);Eval (Member 7 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'False\fcf-containersLookupExample::kind! Eval (Lookup 5 =<< FromList '[ '(5,"a"), '(3,"b")])=) 35) =<< FromList '[ '(5,50), '(3,30)])Eval (Partition ((>=) 35) =<< FromList '[ '(5,50), '(3,30)]) :: (NatMap TL.Natural, NatMap TL.Natural)0= '( 'NatMap '[ '(3, 30)], 'NatMap '[ '(5, 50)])gfcf-containers FilterWithKeyExample:kind! Eval (FilterWithKey (>=) =<< FromList '[ '(3,5), '(6,4)])Eval (FilterWithKey (>=) =<< FromList '[ '(3,5), '(6,4)]) :: NatMap TL.Natural= 'NatMap '[ '(6, 4)]hfcf-containersFilterExample:kind! Eval (Filter ((>=) 35) =<< FromList '[ '(5,50), '(3,30)])Eval (Filter ((>=) 35) =<< FromList '[ '(5,50), '(3,30)]) :: NatMap TL.Natural= 'NatMap '[ '(3, 30)]ifcf-containersToListExample8:kind! Eval (ToList =<< FromList '[ '(5,"a"), '(3,"b")])Eval (ToList =<< FromList '[ '(5,"a"), '(3,"b")]) :: [(TL.Natural, TL.Symbol)]= '[ '(5, "a"), '(3, "b")]:kind! Eval (ToList =<< Empty),Eval (ToList =<< Empty) :: [(TL.Natural, v)]= '[]jfcf-containersAssocsExample8:kind! Eval (Assocs =<< FromList '[ '(5,"a"), '(3,"b")])Eval (Assocs =<< FromList '[ '(5,"a"), '(3,"b")]) :: [(TL.Natural, TL.Symbol)]= '[ '(5, "a"), '(3, "b")]:kind! Eval (Assocs =<< Empty),Eval (Assocs =<< Empty) :: [(TL.Natural, v)]= '[]kfcf-containersKeysExample6:kind! Eval (Keys =<< FromList '[ '(5,"a"), '(3,"b")])?Eval (Keys =<< FromList '[ '(5,"a"), '(3,"b")]) :: [TL.Natural] = '[5, 3]:kind! Eval (Keys =<< Empty)%Eval (Keys =<< Empty) :: [TL.Natural]= '[]lfcf-containersElemsExample7:kind! Eval (Elems =<< FromList '[ '(5,"a"), '(3,"b")])?Eval (Elems =<< FromList '[ '(5,"a"), '(3,"b")]) :: [TL.Symbol] = '["a", "b"]:kind! Eval (Elems =<< Empty)Eval (Elems =<< Empty) :: [v]= '[]mfcf-containersFoldrFold the values in the map using the given right-associative binary operator, such that 'foldr f z == foldr f z . elems'.Note: the order of values in NatMap is not well defined at the moment.Example:kind! Eval (Fcf.Data.NatMap.Foldr (+) 0 =<< (FromList '[ '(1,1), '(2,2)]))Eval (Fcf.Data.NatMap.Foldr (+) 0 =<< (FromList '[ '(1,1), '(2,2)])) :: TL.Natural= 3nfcf-containers NatMapWithKeyExampleofcf-containersMapExample:kind! Eval (Fcf.Data.NatMap.Map (AppendSymbol "x") =<< FromList '[ '(5,"a"), '(3,"b")])Eval (Fcf.Data.NatMap.Map (AppendSymbol "x") =<< FromList '[ '(5,"a"), '(3,"b")]) :: NatMap TL.Symbol$= 'NatMap '[ '(5, "xa"), '(3, "xb")]pfcf-containersDisjointExample:kind! Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")])))Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")]))) :: Bool= 'False:kind! Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(2,"B"), '(7,"C")])))Eval (Disjoint (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(2,"B"), '(7,"C")]))) :: Bool= 'True0:kind! Eval (Disjoint (Eval Empty) (Eval Empty))1Eval (Disjoint (Eval Empty) (Eval Empty)) :: Bool= 'Trueqfcf-containers IntersectionExample:kind! Eval (Intersection (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")])))Eval (Intersection (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")]))) :: NatMap TL.Symbol= 'NatMap '[ '(5, "b")]rfcf-containers DifferenceExample:kind! Eval (Difference (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")])))Eval (Difference (Eval (FromList '[ '(3,"a"), '(5,"b")])) (Eval (FromList '[ '(5,"B"), '(7,"C")]))) :: NatMap TL.Symbol= 'NatMap '[ '(3, "a")]sfcf-containersUnionExample:kind! Eval (Union (Eval (FromList '[ '(5,"a"), '(3,"b")])) (Eval (FromList '[ '(5,"A"), '(7,"c")])) )Eval (Union (Eval (FromList '[ '(5,"a"), '(3,"b")])) (Eval (FromList '[ '(5,"A"), '(7,"c")])) ) :: NatMap TL.Symbol-= 'NatMap '[ '(7, "c"), '(5, "a"), '(3, "b")]tfcf-containersSizeExample6:kind! Eval (Size =<< FromList '[ '(5,"a"), '(3,"b")])=Eval (Size =<< FromList '[ '(5,"a"), '(3,"b")]) :: TL.Natural= 2ufcf-containersNullExample6:kind! Eval (Null =<< FromList '[ '(5,"a"), '(3,"b")])7Eval (Null =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'False:kind! Eval (Null =<< Empty)Eval (Null =<< Empty) :: Bool= 'Truevfcf-containers NotMemberExample=:kind! Eval (NotMember 5 =<< FromList '[ '(5,"a"), '(3,"b")])>Eval (NotMember 5 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'False=:kind! Eval (NotMember 7 =<< FromList '[ '(5,"a"), '(3,"b")])>Eval (NotMember 7 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'Truewfcf-containersMemberExample::kind! Eval (Member 5 =<< FromList '[ '(5,"a"), '(3,"b")]);Eval (Member 5 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'True::kind! Eval (Member 7 =<< FromList '[ '(5,"a"), '(3,"b")]);Eval (Member 7 =<< FromList '[ '(5,"a"), '(3,"b")]) :: Bool= 'Falsexfcf-containersLookupExample::kind! Eval (Lookup 5 =<< FromList '[ '(5,"a"), '(3,"b")])Eval (FromList '[ '(1,"haa"), '(2,"hoo")]) :: NatMap TL.Symbol&= 'NatMap '[ '(1, "haa"), '(2, "hoo")]~fcf-containers SingletonExample:kind! Eval (Singleton 1 "haa"),Eval (Singleton 1 "haa") :: NatMap TL.Symbol= 'NatMap '[ '(1, "haa")]fcf-containersEmptyExample':kind! (Eval Empty :: NatMap TL.Symbol)4(Eval Empty :: NatMap TL.Symbol) :: NatMap TL.Symbol = 'NatMap '[]$:kind! (Eval Empty :: NatMap String).(Eval Empty :: NatMap String) :: NatMap [Char] = 'NatMap '[]+See also the other examples in this module.fcf-containers1A type corresponding to IntMap in the containers.The representation is based on type-level lists. Please, do not use that fact but rather use the exposed API. (We hope to change the internal data type to balanced tree similar to the one used in containers. See TODO.md.)fghijklmnopqrstuvwxyz{|}~utxwvplkj~|{zsrqyonmhgf}i -Set data-structure for type-level programming(c) gspia 2020-BSDgspia Safe-Inferred !01fcf-containers#Get the type-level list out of the .Example 7:kind! Eval (ToList =<< PowerSet =<< FromList '[1,2,3])Eval (ToList =<< PowerSet =<< FromList '[1,2,3]) :: [Set TL.Natural] = '[ 'Set '[], 'Set '[3], 'Set '[2], 'Set '[2, 3], 'Set '[1], 'Set '[1, 2], 'Set '[1, 3], 'Set '[1, 2, 3]] :kind! Eval (Qsort NatListOrd =<< Map ToList =<< ToList =<< PowerSet =<< FromList '[1,2,3])Eval (Qsort NatListOrd =<< Map ToList =<< ToList =<< PowerSet =<< FromList '[1,2,3]) :: [[TL.Natural]] = '[ '[], '[1], '[1, 2], '[1, 2, 3], '[1, 3], '[2], '[2, 3], '[3]]fcf-containers5Use FromList to construct a Set from type-level list.Example :kind! Eval (FromList '[1, 2])9Eval (FromList '[1, 2]) :: Set TL.Natural = 'Set '[1, 2]fcf-containersCalculate the power sets of a given type-level list. The algorithm is based on Gray codes.Example 4:kind! Eval (PowerSet =<< FromList '["a", "b", "c"])Eval (PowerSet =<< FromList '["a", "b", "c"]) :: Set (Set TL.Symbol) = 'Set '[ 'Set '[], 'Set '["c"], 'Set '["b"], 'Set '["b", "c"], 'Set '["a"], 'Set '["a", "b"], 'Set '["a", "c"], 'Set '["a", "b", "c"]] ;:kind! Eval (PowerSet =<< FromList '[Int, Char, Maybe Int])Eval (PowerSet =<< FromList '[Int, Char, Maybe Int]) :: Set (Set (*)) = 'Set '[ 'Set '[], 'Set '[Maybe Int], 'Set '[Char], 'Set '[Char, Maybe Int], 'Set '[Int], 'Set '[Int, Char], 'Set '[Int, Maybe Int], 'Set '[Int, Char, Maybe Int]]fcf-containersType-level set intersection.Example :kind! Eval (Intersection (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7])))Eval (Intersection (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7]))) :: Set TL.Natural = 'Set '[5]fcf-containersType-level set difference.Example :kind! Eval (Difference (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7])))Eval (Difference (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7]))) :: Set TL.Natural = 'Set '[3]fcf-containersType-level set union.Example :kind! Eval (Union (Eval (FromList '[5, 3])) (Eval (FromList '[5, 7])) )Eval (Union (Eval (FromList '[5, 3])) (Eval (FromList '[5, 7])) ) :: Set TL.Natural = 'Set '[7, 5, 3]fcf-containersIsProperSubsetOfExample :kind! Eval (IsProperSubsetOf ('Set '[0,1,2,3,4]) ('Set '[0,1,2,3,4]))Eval (IsProperSubsetOf ('Set '[0,1,2,3,4]) ('Set '[0,1,2,3,4])) :: Bool = 'False :kind! Eval (IsProperSubsetOf ('Set '[0,2,1,3]) ('Set '[0,1,2,3,4]))Eval (IsProperSubsetOf ('Set '[0,2,1,3]) ('Set '[0,1,2,3,4])) :: Bool = 'Truefcf-containers IsSubsetOfExample 7:kind! Eval (IsSubsetOf ('Set '[]) ('Set '[0,1,2,3,4]))Eval (IsSubsetOf ('Set '[]) ('Set '[0,1,2,3,4])) :: Bool = 'True ::kind! Eval (IsSubsetOf ('Set '[0,1]) ('Set '[0,1,2,3,4]))Eval (IsSubsetOf ('Set '[0,1]) ('Set '[0,1,2,3,4])) :: Bool = 'True :kind! Eval (IsSubsetOf ('Set '[0,2,1,3,4]) ('Set '[0,1,2,3,4]))Eval (IsSubsetOf ('Set '[0,2,1,3,4]) ('Set '[0,1,2,3,4])) :: Bool = 'True :kind! Eval (IsSubsetOf ('Set '[0,1,2,3,4,5]) ('Set '[0,1,2,3,4]))Eval (IsSubsetOf ('Set '[0,1,2,3,4,5]) ('Set '[0,1,2,3,4])) :: Bool = 'Falsefcf-containersSizeExample ':kind! Eval (Size =<< FromList '[5, 3])3Eval (Size =<< FromList '[5, 3]) :: TL.Natural = 2fcf-containersNullExample ':kind! Eval (Null =<< FromList '[5, 3])2Eval (Null =<< FromList '[5, 3]) :: Bool = 'False :kind! Eval (Null =<< Empty)&Eval (Null =<< Empty) :: Bool = 'Truefcf-containers NotMemberExample .:kind! Eval (NotMember 5 =<< FromList '[5, 3])9Eval (NotMember 5 =<< FromList '[5, 3]) :: Bool = 'False .:kind! Eval (NotMember 7 =<< FromList '[5, 3])8Eval (NotMember 7 =<< FromList '[5, 3]) :: Bool = 'Truefcf-containersMemberExample +:kind! Eval (Member 5 =<< FromList '[5, 3])5Eval (Member 5 =<< FromList '[5, 3]) :: Bool = 'True +:kind! Eval (Member 7 =<< FromList '[5, 3])6Eval (Member 7 =<< FromList '[5, 3]) :: Bool = 'Falsefcf-containersDeleteExample +:kind! Eval (Delete 5 =<< FromList '[5, 3])Eval (Delete 5 =<< FromList '[5, 3]) :: Set TL.Natural = 'Set '[3] +:kind! Eval (Delete 7 =<< FromList '[5, 3])Eval (Delete 7 =<< FromList '[5, 3]) :: Set TL.Natural = 'Set '[5, 3]fcf-containersInsertExample +:kind! Eval (Insert 3 =<< FromList '[1, 2])Eval (Insert 3 =<< FromList '[1, 2]) :: Set TL.Natural = 'Set '[3, 1, 2] +:kind! Eval (Insert 2 =<< FromList '[1, 2])Eval (Insert 2 =<< FromList '[1, 2]) :: Set TL.Natural = 'Set '[1, 2]fcf-containers SingletonExample :kind! Eval (Singleton 1)1Eval (Singleton 1) :: Set TL.Natural = 'Set '[1]fcf-containersEmptyExample :kind! (Eval Empty :: Set Nat)5(Eval Empty :: Set Nat) :: Set TL.Natural = 'Set '[]+See also the other examples in this module.fcf-containersSet-definition. &Type-level Symbol helpers for Fcf libs(c) gspia 2023-BSDgspia Safe-Inferred !01   Type level symbols(c) gspia 2020-BSDgspia Safe-Inferred !01 fcf-containersEquality of symbolsExample:kind! Eval ("b" == "a")Eval ("b" == "a") :: Bool= 'Falsefcf-containers#Larger-than comparison for symbols.Example:kind! Eval ("b" > "a")Eval ("b" > "a") :: Bool= 'Truefcf-containers!Less-than comparison for symbols.Example:kind! Eval ("a" < "b")Eval ("a" < "b") :: Bool= 'Truefcf-containers,Larger-than-or-equal comparison for symbols.Example:kind! Eval ("b" >= "a")Eval ("b" >= "a") :: Bool= 'Truefcf-containers*Less-than-or-equal comparison for symbols.Example:kind! Eval ("b" <= "a")Eval ("b" <= "a") :: Bool= 'Falsefcf-containersSymbolOrd - compare two symbols and give type-level Ordering ( $ 'LT $, $ 'EQ $ or $ 'GT $ ).Example:kind! Eval (SymbolOrd "a" "b")$Eval (SymbolOrd "a" "b") :: Ordering= 'LTfcf-containersIsDigitExample:kind! Eval (IsDigit "3")Eval (IsDigit "3") :: Bool= 'True:kind! Eval (IsDigit "a")Eval (IsDigit "a") :: Bool= 'Falsefcf-containers IsSpaceDelimExample:kind! Eval (IsSpaceDelim "a")Eval (IsSpaceDelim "a") :: Bool= 'False:kind! Eval (IsSpaceDelim "\n") Eval (IsSpaceDelim "\n") :: Bool= 'Truefcf-containersIsTabExample:kind! Eval (IsTab "a")Eval (IsTab "a") :: Bool= 'False:kind! Eval (IsTab "\t")Eval (IsTab "\t") :: Bool= 'Truefcf-containers IsNewlineExample:kind! Eval (IsNewLine "a")Eval (IsNewLine "a") :: Bool= 'False:kind! Eval (IsNewLine "\n")Eval (IsNewLine "\n") :: Bool= 'Truefcf-containersIsSpaceExample:kind! Eval (IsSpace "a")Eval (IsSpace "a") :: Bool= 'False:kind! Eval (IsSpace " ")Eval (IsSpace " ") :: Bool= 'Truefcf-containersIntercalate type-level symbols.Example1:kind! Eval (Intercalate "+" '["aa", "bb", "cc"])4Eval (Intercalate "+" '["aa", "bb", "cc"]) :: Symbol = "aa+bb+cc"%:kind! Eval (Intercalate "+" '["aa"])(Eval (Intercalate "+" '["aa"]) :: Symbol= "aa"!:kind! Eval (Intercalate "+" '[])$Eval (Intercalate "+" '[]) :: Symbol= ""fcf-containersAppend two type-level symbols.Example :kind! Eval (Append "hmm" " ok")#Eval (Append "hmm" " ok") :: Symbol = "hmm ok"  +Type-level Text data structure with methods(c) gspia 2020-BSDgspia Safe-Inferred !01fcf-containersHelper, from symbols-package. The character tree that is needed for handling the initial character of a symbol.fcf-containersHelper, from symbols-package.fcf-containersHelper, from symbols-package.fcf-containersHelper, from symbols-package.fcf-containersHelper, from symbols-package.fcf-containersHelper, from symbols-package.fcf-containersEval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok hmm ab"fcf-containersUnlines for type-level text. This adds a newline to each Text and then concats them.Example=:kind! Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"])>Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok\nhmm\nab\n"fcf-containersWords for type-level text.Example.:kind! Eval (Words =<< Singleton "ok hmm\nab")1Eval (Words =<< Singleton "ok hmm\nab") :: [Text])= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]fcf-containersLines for type-level text.Example/:kind! Eval (Lines =<< Singleton "ok\nhmm\nab")2Eval (Lines =<< Singleton "ok\nhmm\nab") :: [Text])= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]fcf-containersHelper for Splitfcf-containersHelper for Splitfcf-containersSplit for type-level text.Example<:kind! Eval (Split S.IsSpace (Eval (Singleton "cd bf abh")))?Eval (Split S.IsSpace (Eval (Singleton "cd bf abh"))) :: [Text])= '[ 'Text "cd", 'Text "bf", 'Text "abh"]fcf-containersHelper for SplitOnfcf-containersHelper for SplitOn:kind! Eval (SOTake '["a", "b"] '[ "c", "d", "a", "b", "f", "g"] '[])Eval (SOTake '["a", "b"] '[ "c", "d", "a", "b", "f", "g"] '[]) :: ([Symbol], [Symbol])= '( '["c", "d"], '["f", "g"])fcf-containersSplitOn for type-level text.Example6:kind! Eval (SplitOn ('Text "ab") ('Text "cdabfgabh"))9Eval (SplitOn ('Text "ab") ('Text "cdabfgabh")) :: [Text]'= '[ 'Text "cd", 'Text "fg", 'Text "h"]fcf-containersStrip the space, newline and tab -symbols from the beginning and and of type-level text.Example':kind! Eval (Strip ('Text " aamu \n"))(Eval (Strip ('Text " aamu \n")) :: Text= 'Text "aamu"fcf-containersDropAround for type-level text.Example5:kind! Eval (DropAround S.IsDigit ('Text "34aamu12"))6Eval (DropAround S.IsDigit ('Text "34aamu12")) :: Text= 'Text "aamu"fcf-containers'DropWhileEnd for type-level text. === Example5:kind! Eval (DropWhileEnd S.IsDigit ('Text "aamu12"))6Eval (DropWhileEnd S.IsDigit ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersDropWhile for type-level text.Example2:kind! Eval (DropWhile S.IsDigit ('Text "12aamu"))3Eval (DropWhile S.IsDigit ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containers!TakeWhileEnd for type-level text.Example?:kind! Eval (TakeWhileEnd (Not <=< S.IsDigit) ('Text "12aamu"))Eval (TakeWhileEnd (Not <=< S.IsDigit) ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containersTakeWhile for type-level text.Example<:kind! Eval (TakeWhile (Not <=< S.IsDigit) ('Text "aamu12"))=Eval (TakeWhile (Not <=< S.IsDigit) ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersDropEnd for type-level text.Example(:kind! Eval (DropEnd 2 ('Text "aamuna")))Eval (DropEnd 2 ('Text "aamuna")) :: Text= 'Text "aamu"fcf-containersDrop for type-level text.Example%:kind! Eval (Drop 2 ('Text "aamuna"))&Eval (Drop 2 ('Text "aamuna")) :: Text= 'Text "muna"fcf-containersTakeEnd for type-level text.Example':kind! Eval (TakeEnd 4 ('Text "haamu"))(Eval (TakeEnd 4 ('Text "haamu")) :: Text= 'Text "aamu"fcf-containersTake for type-level text.Example$:kind! Eval (Take 4 ('Text "aamun"))%Eval (Take 4 ('Text "aamun")) :: Text= 'Text "aamu"fcf-containersAll for type-level text.Example+:kind! Eval (All S.IsDigit ('Text "aamu1")),Eval (All S.IsDigit ('Text "aamu1")) :: Bool= 'False):kind! Eval (All S.IsDigit ('Text "321"))*Eval (All S.IsDigit ('Text "321")) :: Bool= 'Truefcf-containersAny for type-level text.Example+:kind! Eval (Any S.IsDigit ('Text "aamu1")),Eval (Any S.IsDigit ('Text "aamu1")) :: Bool= 'True*:kind! Eval (Any S.IsDigit ('Text "aamu"))+Eval (Any S.IsDigit ('Text "aamu")) :: Bool= 'Falsefcf-containersFConcatMap for type-level text.Example:{ "data IsIsymb :: Symbol -> Exp Bool2type instance Eval (IsIsymb s) = Eval ("i" S.== s)#data Isymb2aa :: Symbol -> Exp Text&type instance Eval (Isymb2aa s) = Eval (If (IsIsymb @@ s) (Pure ('Text "aa")) (Pure ('Text s)) ):}2:kind! Eval (FConcatMap Isymb2aa ('Text "imu ih"))3Eval (FConcatMap Isymb2aa ('Text "imu ih")) :: Text= 'Text "aamu aah"fcf-containersConcat for type-level text.Example1:kind! Eval (Concat '[ 'Text "la", 'Text "kana"])2Eval (Concat '[ 'Text "la", 'Text "kana"]) :: Text= 'Text "lakana"fcf-containersReplace for type-level text.Example:kind! Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa"))Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa")) :: Text= 'Text "laulattaa"fcf-containersReverse for type-level text.Example$:kind! Eval (Reverse ('Text "aamu"))%Eval (Reverse ('Text "aamu")) :: Text= 'Text "umaa"0:kind! Eval (Reverse =<< Reverse ('Text "aamu"))1Eval (Reverse =<< Reverse ('Text "aamu")) :: Text= 'Text "aamu"fcf-containers Intersperse for type-level text.Example,:kind! Eval (Intersperse "." ('Text "aamu"))-Eval (Intersperse "." ('Text "aamu")) :: Text= 'Text "a.a.m.u"fcf-containers Intercalate for type-level text.Example:kind! Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"]))Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"])) :: Text= 'Text "aamu & valo"fcf-containersFMap for type-level text.Example:{ "data IsIsymb :: Symbol -> Exp Bool2type instance Eval (IsIsymb s) = Eval ("i" S.== s)$data Isymb2e :: Symbol -> Exp Symbol%type instance Eval (Isymb2e s) = Eval (If (IsIsymb @@ s) (Pure "e") (Pure s) ):}(:kind! Eval (FMap Isymb2e ('Text "imu")))Eval (FMap Isymb2e ('Text "imu")) :: Text = 'Text "emu"fcf-containersCompare the length of type-level text to given Nat and give the Ordering.Example,:kind! Eval (CompareLength ('Text "aamu") 3)1Eval (CompareLength ('Text "aamu") 3) :: Ordering= 'GTfcf-containers5Take all except the last symbol from type-level text.Example":kind! Eval (Init ('Text "aamun")))Eval (Init ('Text "aamun")) :: Maybe Text= 'Just ('Text "aamu"):kind! Eval (Init ('Text ""))$Eval (Init ('Text "")) :: Maybe Text = 'Nothingfcf-containers"Get the tail of a type-level text.Example":kind! Eval (Tail ('Text "haamu")))Eval (Tail ('Text "haamu")) :: Maybe Text= 'Just ('Text "aamu"):kind! Eval (Tail ('Text ""))$Eval (Tail ('Text "")) :: Maybe Text = 'Nothingfcf-containers(Get the first symbol of type-level text.Example!:kind! Eval (Head ('Text "aamu"))*Eval (Head ('Text "aamu")) :: Maybe Symbol = 'Just "a":kind! Eval (Head ('Text ""))&Eval (Head ('Text "")) :: Maybe Symbol = 'Nothingfcf-containers)Get the last symbol from type-level text.Example$:kind! Eval (Unsnoc ('Text "aamun"))5Eval (Unsnoc ('Text "aamun")) :: Maybe (Symbol, Text)= 'Just '("n", 'Text "aamu"):kind! Eval (Unsnoc ('Text ""))0Eval (Unsnoc ('Text "")) :: Maybe (Symbol, Text) = 'Nothingfcf-containers*Get the first symbol from type-level text.Example$:kind! Eval (Uncons ('Text "haamu"))5Eval (Uncons ('Text "haamu")) :: Maybe (Symbol, Text)= 'Just '("h", 'Text "aamu"):kind! Eval (Uncons ('Text ""))0Eval (Uncons ('Text "")) :: Maybe (Symbol, Text) = 'Nothingfcf-containersAppend two type-level texts.Example.:kind! Eval (Append ('Text "aa") ('Text "mu"))/Eval (Append ('Text "aa") ('Text "mu")) :: Text= 'Text "aamu"fcf-containers-Add a symbol to the end of a type-level text.Example$:kind! Eval (Snoc ('Text "aam") "u")%Eval (Snoc ('Text "aam") "u") :: Text= 'Text "aamu"fcf-containers3Add a symbol to the beginning of a type-level text.Example%:kind! Eval (Cons "h" ('Text "aamu"))&Eval (Cons "h" ('Text "aamu")) :: Text= 'Text "haamu"fcf-containersLengthExample':kind! Eval (Length =<< Singleton "ab").Eval (Length =<< Singleton "ab") :: TL.Natural= 2fcf-containersNullExample:kind! Eval (Null ('Text "ab")) Eval (Null ('Text "ab")) :: Bool= 'False:kind! Eval (Null =<< Empty)Eval (Null =<< Empty) :: Bool= 'Truefcf-containersToSymbolExample?:kind! Eval (ToSymbol =<< FromSymbolList '["w", "o", "r", "d"])Eval (ToSymbol =<< FromSymbolList '["w", "o", "r", "d"]) :: Symbol= "word"fcf-containersSplit  to single character  list.Example3:kind! Eval (ToList =<< FromSymbolList '["a", "b"])6Eval (ToList =<< FromSymbolList '["a", "b"]) :: [Text]= '[ 'Text "a", 'Text "b"]fcf-containers#Get the type-level list out of the .Example9:kind! Eval (ToSymbolList =<< FromSymbolList '["a", "b"])>Eval (ToSymbolList =<< FromSymbolList '["a", "b"]) :: [Symbol] = '["a", "b"]fcf-containers6Use FromList to construct a Text from type-level list.Example:kind! Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) :: Text = 'Text "hellurei"fcf-containers SingletonExample:kind! Eval (Singleton "a")Eval (Singleton "a") :: Text = 'Text "a"fcf-containersEmptyExample:kind! (Eval Empty :: Text)(Eval Empty :: Text) :: Text = 'Text ""+See also the other examples in this module.fcf-containers is a data structure, that is, a list to hold type-level symbols of length one.00+Type-level Text data structure with methods(c) gspia 2020-BSDgspia Safe-Inferred !01E2fcf-containersIsInfixOf for type-level text.Example9:kind! Eval (IsInfixOf ('Text "mia") ('Text "aamiainen")):Eval (IsInfixOf ('Text "mia") ('Text "aamiainen")) :: Bool= 'Truefcf-containersIsSuffixOf for type-level text.Example::kind! Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen"));Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen")) :: Bool= 'Truefcf-containersIsPrefixOf for type-level text.Example9:kind! Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen")):Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen")) :: Bool= 'Truefcf-containers'Unwords for type-level text. This uses . to add space-symbol between the given texts.Example=:kind! Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"])>Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok hmm ab"fcf-containersUnlines for type-level text. This adds a newline to each Text and then concats them.Example=:kind! Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"])>Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok\nhmm\nab\n"fcf-containersWords for type-level text.Example.:kind! Eval (Words =<< Singleton "ok hmm\nab")1Eval (Words =<< Singleton "ok hmm\nab") :: [Text])= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]fcf-containersLines for type-level text.Example/:kind! Eval (Lines =<< Singleton "ok\nhmm\nab")2Eval (Lines =<< Singleton "ok\nhmm\nab") :: [Text])= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]fcf-containersHelper for Splitfcf-containersHelper for Splitfcf-containersSplit for type-level text.Example<:kind! Eval (Split S.IsSpace (Eval (Singleton "cd bf abh")))?Eval (Split S.IsSpace (Eval (Singleton "cd bf abh"))) :: [Text])= '[ 'Text "cd", 'Text "bf", 'Text "abh"]fcf-containersHelper for SplitOnfcf-containersHelper for SplitOn:kind! Eval (SOTake '["a", "b"] '[ "c", "d", "a", "b", "f", "g"] '[])Eval (SOTake '["a", "b"] '[ "c", "d", "a", "b", "f", "g"] '[]) :: ([Symbol], [Symbol])= '( '["c", "d"], '["f", "g"])fcf-containersSplitOn for type-level text.Example6:kind! Eval (SplitOn ('Text "ab") ('Text "cdabfgabh"))9Eval (SplitOn ('Text "ab") ('Text "cdabfgabh")) :: [Text]'= '[ 'Text "cd", 'Text "fg", 'Text "h"]fcf-containersStrip the space, newline and tab -symbols from the beginning and and of type-level text.Example':kind! Eval (Strip ('Text " aamu \n"))(Eval (Strip ('Text " aamu \n")) :: Text= 'Text "aamu"fcf-containersDropAround for type-level text.Example5:kind! Eval (DropAround S.IsDigit ('Text "34aamu12"))6Eval (DropAround S.IsDigit ('Text "34aamu12")) :: Text= 'Text "aamu"fcf-containers'DropWhileEnd for type-level text. === Example5:kind! Eval (DropWhileEnd S.IsDigit ('Text "aamu12"))6Eval (DropWhileEnd S.IsDigit ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersDropWhile for type-level text.Example2:kind! Eval (DropWhile S.IsDigit ('Text "12aamu"))3Eval (DropWhile S.IsDigit ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containers!TakeWhileEnd for type-level text.Example?:kind! Eval (TakeWhileEnd (Not <=< S.IsDigit) ('Text "12aamu"))Eval (TakeWhileEnd (Not <=< S.IsDigit) ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containersTakeWhile for type-level text.Example<:kind! Eval (TakeWhile (Not <=< S.IsDigit) ('Text "aamu12"))=Eval (TakeWhile (Not <=< S.IsDigit) ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersDropEnd for type-level text.Example(:kind! Eval (DropEnd 2 ('Text "aamuna")))Eval (DropEnd 2 ('Text "aamuna")) :: Text= 'Text "aamu"fcf-containersDrop for type-level text.Example%:kind! Eval (Drop 2 ('Text "aamuna"))&Eval (Drop 2 ('Text "aamuna")) :: Text= 'Text "muna"fcf-containersTakeEnd for type-level text.Example':kind! Eval (TakeEnd 4 ('Text "haamu"))(Eval (TakeEnd 4 ('Text "haamu")) :: Text= 'Text "aamu"fcf-containersTake for type-level text.Example$:kind! Eval (Take 4 ('Text "aamun"))%Eval (Take 4 ('Text "aamun")) :: Text= 'Text "aamu"fcf-containersAll for type-level text.Example+:kind! Eval (All S.IsDigit ('Text "aamu1")),Eval (All S.IsDigit ('Text "aamu1")) :: Bool= 'False):kind! Eval (All S.IsDigit ('Text "321"))*Eval (All S.IsDigit ('Text "321")) :: Bool= 'Truefcf-containersAny for type-level text.Example+:kind! Eval (Any S.IsDigit ('Text "aamu1")),Eval (Any S.IsDigit ('Text "aamu1")) :: Bool= 'True*:kind! Eval (Any S.IsDigit ('Text "aamu"))+Eval (Any S.IsDigit ('Text "aamu")) :: Bool= 'Falsefcf-containersFConcatMap for type-level text.Example:{ "data IsIsymb :: Symbol -> Exp Bool2type instance Eval (IsIsymb s) = Eval ("i" S.== s)#data Isymb2aa :: Symbol -> Exp Text&type instance Eval (Isymb2aa s) = Eval (If (IsIsymb @@ s) (Pure ('Text "aa")) (Pure ('Text s)) ):}2:kind! Eval (FConcatMap Isymb2aa ('Text "imu ih"))3Eval (FConcatMap Isymb2aa ('Text "imu ih")) :: Text= 'Text "aamu aah"fcf-containersConcat for type-level text.Example1:kind! Eval (Concat '[ 'Text "la", 'Text "kana"])2Eval (Concat '[ 'Text "la", 'Text "kana"]) :: Text= 'Text "lakana"fcf-containersReplace for type-level text.Example:kind! Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa"))Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa")) :: Text= 'Text "laulattaa"fcf-containersReverse for type-level text.Example$:kind! Eval (Reverse ('Text "aamu"))%Eval (Reverse ('Text "aamu")) :: Text= 'Text "umaa"0:kind! Eval (Reverse =<< Reverse ('Text "aamu"))1Eval (Reverse =<< Reverse ('Text "aamu")) :: Text= 'Text "aamu"fcf-containers Intersperse for type-level text.Example,:kind! Eval (Intersperse "." ('Text "aamu"))-Eval (Intersperse "." ('Text "aamu")) :: Text= 'Text "a.a.m.u"fcf-containers Intercalate for type-level text.Example:kind! Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"]))Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"])) :: Text= 'Text "aamu & valo"fcf-containersFMap for type-level text.Example:{ "data IsIsymb :: Symbol -> Exp Bool2type instance Eval (IsIsymb s) = Eval ("i" S.== s)$data Isymb2e :: Symbol -> Exp Symbol%type instance Eval (Isymb2e s) = Eval (If (IsIsymb @@ s) (Pure "e") (Pure s) ):}(:kind! Eval (FMap Isymb2e ('Text "imu")))Eval (FMap Isymb2e ('Text "imu")) :: Text = 'Text "emu"fcf-containersCompare the length of type-level text to given Nat and give the Ordering.Example,:kind! Eval (CompareLength ('Text "aamu") 3)1Eval (CompareLength ('Text "aamu") 3) :: Ordering= 'GTfcf-containers5Take all except the last symbol from type-level text.Example":kind! Eval (Init ('Text "aamun")))Eval (Init ('Text "aamun")) :: Maybe Text= 'Just ('Text "aamu"):kind! Eval (Init ('Text ""))$Eval (Init ('Text "")) :: Maybe Text = 'Nothingfcf-containers"Get the tail of a type-level text.Example":kind! Eval (Tail ('Text "haamu")))Eval (Tail ('Text "haamu")) :: Maybe Text= 'Just ('Text "aamu"):kind! Eval (Tail ('Text ""))$Eval (Tail ('Text "")) :: Maybe Text = 'Nothingfcf-containers(Get the first symbol of type-level text.Example!:kind! Eval (Head ('Text "aamu"))*Eval (Head ('Text "aamu")) :: Maybe Symbol = 'Just "a":kind! Eval (Head ('Text ""))&Eval (Head ('Text "")) :: Maybe Symbol = 'Nothingfcf-containers)Get the last symbol from type-level text.Example$:kind! Eval (Unsnoc ('Text "aamun"))5Eval (Unsnoc ('Text "aamun")) :: Maybe (Symbol, Text)= 'Just '("n", 'Text "aamu"):kind! Eval (Unsnoc ('Text ""))0Eval (Unsnoc ('Text "")) :: Maybe (Symbol, Text) = 'Nothingfcf-containers*Get the first symbol from type-level text.Example$:kind! Eval (Uncons ('Text "haamu"))5Eval (Uncons ('Text "haamu")) :: Maybe (Symbol, Text)= 'Just '("h", 'Text "aamu"):kind! Eval (Uncons ('Text ""))0Eval (Uncons ('Text "")) :: Maybe (Symbol, Text) = 'Nothingfcf-containersAppend two type-level texts.Example.:kind! Eval (Append ('Text "aa") ('Text "mu"))/Eval (Append ('Text "aa") ('Text "mu")) :: Text= 'Text "aamu"fcf-containers-Add a symbol to the end of a type-level text.Example$:kind! Eval (Snoc ('Text "aam") "u")%Eval (Snoc ('Text "aam") "u") :: Text= 'Text "aamu"fcf-containers3Add a symbol to the beginning of a type-level text.Example%:kind! Eval (Cons "h" ('Text "aamu"))&Eval (Cons "h" ('Text "aamu")) :: Text= 'Text "haamu"fcf-containersLengthExample':kind! Eval (Length =<< Singleton "ab").Eval (Length =<< Singleton "ab") :: TL.Natural= 2fcf-containersNullExample:kind! Eval (Null ('Text "ab")) Eval (Null ('Text "ab")) :: Bool= 'False:kind! Eval (Null =<< Empty)Eval (Null =<< Empty) :: Bool= 'Truefcf-containersToSymbolExample?:kind! Eval (ToSymbol =<< FromSymbolList '["w", "o", "r", "d"])Eval (ToSymbol =<< FromSymbolList '["w", "o", "r", "d"]) :: Symbol= "word"fcf-containersSplit  to single character  list.Example3:kind! Eval (ToList =<< FromSymbolList '["a", "b"])6Eval (ToList =<< FromSymbolList '["a", "b"]) :: [Text]= '[ 'Text "a", 'Text "b"]fcf-containers#Get the type-level list out of the .Example9:kind! Eval (ToSymbolList =<< FromSymbolList '["a", "b"])>Eval (ToSymbolList =<< FromSymbolList '["a", "b"]) :: [Symbol] = '["a", "b"]fcf-containers6Use FromList to construct a Text from type-level list.Example:kind! Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) :: Text = 'Text "hellurei"fcf-containers SingletonExample:kind! Eval (Singleton "a")Eval (Singleton "a") :: Text = 'Text "a"fcf-containersEmptyExample:kind! (Eval Empty :: Text)(Eval Empty :: Text) :: Text = 'Text ""+See also the other examples in this module.fcf-containers is a data structure, that is, a list to hold type-level symbols of length one.00Type-level tuple functions(c) gspia 2020-BSDgspia Safe-Inferred!01[fcf-containers5-tuple to allow for partial application of 4-tuple at the type levelfcf-containers4-tuple to allow for partial application of 4-tuple at the type levelfcf-containers3-tuple to allow for partial application of 3-tuple at the type levelfcf-containers2-tuple to allow for partial application of 2-tuple at the type levelfcf-containersSwapExample:kind! Eval (Swap '(1, 2))/Eval (Swap '(1, 2)) :: (TL.Natural, TL.Natural) = '(2, 1)+Type-level Text data structure with methods(c) gspia 2020-BSDgspia Safe-Inferred !018fcf-containersIsInfixOf for type-level text.Example9:kind! Eval (IsInfixOf ('Text "mia") ('Text "aamiainen")):Eval (IsInfixOf ('Text "mia") ('Text "aamiainen")) :: Bool= 'Truefcf-containersIsSuffixOf for type-level text.Example::kind! Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen"));Eval (IsSuffixOf ('Text "nen") ('Text "aamiainen")) :: Bool= 'Truefcf-containersIsPrefixOf for type-level text.Example9:kind! Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen")):Eval (IsPrefixOf ('Text "aa") ('Text "aamiainen")) :: Bool= 'Truefcf-containers'Unwords for type-level text. This uses . to add space-symbol between the given texts.Example=:kind! Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"])>Eval (Unwords '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok hmm ab"fcf-containersUnlines for type-level text. This adds a newline to each Text and then concats them.Example=:kind! Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"])>Eval (Unlines '[ 'Text "ok", 'Text "hmm", 'Text "ab"]) :: Text= 'Text "ok\nhmm\nab\n"fcf-containersWords for type-level text.Example/:kind! Eval (Words =<< FromSymbol "ok hmm\nab")2Eval (Words =<< FromSymbol "ok hmm\nab") :: [Text])= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]fcf-containersLines for type-level text.Example0:kind! Eval (Lines =<< FromSymbol "ok\nhmm\nab")3Eval (Lines =<< FromSymbol "ok\nhmm\nab") :: [Text])= '[ 'Text "ok", 'Text "hmm", 'Text "ab"]fcf-containersHelper for Splitfcf-containersHelper for Splitfcf-containersSplitSymbol for type-level text. This takes Symbol to Bool function.Example:kind! Eval (SplitSymbol Sym.IsSpace (Eval (FromSymbol "cd bf abh")))Eval (SplitSymbol Sym.IsSpace (Eval (FromSymbol "cd bf abh"))) :: [Text])= '[ 'Text "cd", 'Text "bf", 'Text "abh"]fcf-containersEval (DropAroundSymbol Sym.IsDigit ('Text "34aamu12")) :: Text= 'Text "aamu"fcf-containersDropAround for type-level text. This takes Char to Bool function.Example3:kind! Eval (DropAround IsDigit ('Text "34aamu12"))4Eval (DropAround IsDigit ('Text "34aamu12")) :: Text= 'Text "aamu"fcf-containers'DropWhileEndSymbol for type-level text.Example=:kind! Eval (DropWhileEndSymbol Sym.IsDigit ('Text "aamu12"))>Eval (DropWhileEndSymbol Sym.IsDigit ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containers!DropWhileEnd for type-level text.Example3:kind! Eval (DropWhileEnd IsDigit ('Text "aamu12"))4Eval (DropWhileEnd IsDigit ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersDropWhileSymbol for type-level text. This takes Symbol to Bool function.Example::kind! Eval (DropWhileSymbol Sym.IsDigit ('Text "12aamu"));Eval (DropWhileSymbol Sym.IsDigit ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containersDropWhile for type-level text. This takes Char to Bool function.Example0:kind! Eval (DropWhile IsDigit ('Text "12aamu"))1Eval (DropWhile IsDigit ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containersTakeWhileEndSymbol for type-level text. This takes Symbol to Bool function.Example:kind! Eval (TakeWhileEndSymbol (Not <=< Sym.IsDigit) ('Text "12aamu"))Eval (TakeWhileEndSymbol (Not <=< Sym.IsDigit) ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containersTakeWhileEnd for type-level text. This takes Char to Bool function.Example=:kind! Eval (TakeWhileEnd (Not <=< IsDigit) ('Text "12aamu"))>Eval (TakeWhileEnd (Not <=< IsDigit) ('Text "12aamu")) :: Text= 'Text "aamu"fcf-containersTakeWhileSymbol for type-level text. This takes Symbol to Bool function.Example:kind! Eval (TakeWhileSymbol (Not <=< Sym.IsDigit) ('Text "aamu12"))Eval (TakeWhileSymbol (Not <=< Sym.IsDigit) ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersTakeWhile for type-level text. This takes Char to Bool function.Example::kind! Eval (TakeWhile (Not <=< IsDigit) ('Text "aamu12"));Eval (TakeWhile (Not <=< IsDigit) ('Text "aamu12")) :: Text= 'Text "aamu"fcf-containersDropEnd for type-level text.Example(:kind! Eval (DropEnd 2 ('Text "aamuna")))Eval (DropEnd 2 ('Text "aamuna")) :: Text= 'Text "aamu"fcf-containersDrop for type-level text.Example%:kind! Eval (Drop 2 ('Text "aamuna"))&Eval (Drop 2 ('Text "aamuna")) :: Text= 'Text "muna"fcf-containersTakeEnd for type-level text.Example':kind! Eval (TakeEnd 4 ('Text "haamu"))(Eval (TakeEnd 4 ('Text "haamu")) :: Text= 'Text "aamu"fcf-containersTake for type-level text.Example$:kind! Eval (Take 4 ('Text "aamun"))%Eval (Take 4 ('Text "aamun")) :: Text= 'Text "aamu"fcf-containersAllSymbol for type-level text. This takes Symbol to Bool function.Example3:kind! Eval (AllSymbol Sym.IsDigit ('Text "aamu1"))4Eval (AllSymbol Sym.IsDigit ('Text "aamu1")) :: Bool= 'False1:kind! Eval (AllSymbol Sym.IsDigit ('Text "321"))2Eval (AllSymbol Sym.IsDigit ('Text "321")) :: Bool= 'Truefcf-containers:All for type-level text. This takes Char to Bool function.Example):kind! Eval (All IsDigit ('Text "aamu1"))*Eval (All IsDigit ('Text "aamu1")) :: Bool= 'False':kind! Eval (All IsDigit ('Text "321"))(Eval (All IsDigit ('Text "321")) :: Bool= 'Truefcf-containersAnySymbol for type-level text. This takes Symbol to Bool function. Note that the given function needs to be compatible... (i.e. operating with symbols of length 1.Example3:kind! Eval (AnySymbol Sym.IsDigit ('Text "aamu1"))4Eval (AnySymbol Sym.IsDigit ('Text "aamu1")) :: Bool= 'True2:kind! Eval (AnySymbol Sym.IsDigit ('Text "aamu"))3Eval (AnySymbol Sym.IsDigit ('Text "aamu")) :: Bool= 'Falsefcf-containers;Any for type-level text. This takes Char to Bool function.Example):kind! Eval (Any IsDigit ('Text "aamu1"))*Eval (Any IsDigit ('Text "aamu1")) :: Bool= 'True(:kind! Eval (Any IsDigit ('Text "aamu")))Eval (Any IsDigit ('Text "aamu")) :: Bool= 'Falsefcf-containersConcatMap for type-level text. This takes Char to Symbol function.fcf-containersConcatMap for type-level text. This takes Char to Text function.Example:{$data DigitsToHoo :: Char -> Exp Text)type instance Eval (DigitsToHoo c) = Eval (If (IsDigit @@ c) (Pure ( 'Text "hoo")) (Singleton c) ):}6:kind! Eval (ConcatMap DigitsToHoo ('Text "haa2hui2"))7Eval (ConcatMap DigitsToHoo ('Text "haa2hui2")) :: Text= 'Text "haahoohuihoo"fcf-containersFConcatMapSymbol for type-level text. This takes Symbol to Text function.Example:{ "data IsIsymb :: Symbol -> Exp Bool4type instance Eval (IsIsymb s) = Eval ("i" Sym.== s)#data Isymb2aa :: Symbol -> Exp Text&type instance Eval (Isymb2aa s) = Eval (If (IsIsymb @@ s) (Pure ('Text "aa")) (Pure ('Text s)) ):}7:kind! Eval (ConcatMapSymbol Isymb2aa ('Text "imu ih"))8Eval (ConcatMapSymbol Isymb2aa ('Text "imu ih")) :: Text= 'Text "aamu aah"fcf-containersConcat for type-level text.Example1:kind! Eval (Concat '[ 'Text "la", 'Text "kana"])2Eval (Concat '[ 'Text "la", 'Text "kana"]) :: Text= 'Text "lakana"fcf-containersReplace for type-level text.Example:kind! Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa"))Eval (Replace ('Text "tu") ('Text "la") ('Text "tuututtaa")) :: Text= 'Text "laulattaa"fcf-containersReverse for type-level text.Example$:kind! Eval (Reverse ('Text "aamu"))%Eval (Reverse ('Text "aamu")) :: Text= 'Text "umaa"0:kind! Eval (Reverse =<< Reverse ('Text "aamu"))1Eval (Reverse =<< Reverse ('Text "aamu")) :: Text= 'Text "aamu"fcf-containers'Intersperse Symbol for type-level text.Example2:kind! Eval (IntersperseSymbol "." ('Text "aamu"))3Eval (IntersperseSymbol "." ('Text "aamu")) :: Text= 'Text "a.a.m.u"fcf-containers%Intersperse Char for type-level text.Example,:kind! Eval (Intersperse '.' ('Text "aamu"))-Eval (Intersperse '.' ('Text "aamu")) :: Text= 'Text "a.a.m.u"fcf-containers Intercalate for type-level text.Example:kind! Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"]))Eval (Intercalate ('Text " & ") ('[ 'Text "aamu", 'Text "valo"])) :: Text= 'Text "aamu & valo"fcf-containersFMap for type-level text.Example:{"data DigitsToX :: Char -> Exp Char'type instance Eval (DigitsToX c) = Eval (If (IsDigit @@ c) (Pure 'X') (Pure c) ):}5:kind! Eval (FMap DigitsToX ('Text "Some4text5oh9."))6Eval (FMap DigitsToX ('Text "Some4text5oh9.")) :: Text= 'Text "SomeXtextXohX."fcf-containersFMapSymbol for type-level text.Example:{ "data IsIsymb :: Symbol -> Exp Bool4type instance Eval (IsIsymb s) = Eval ("i" Sym.== s)$data Isymb2e :: Symbol -> Exp Symbol%type instance Eval (Isymb2e s) = Eval (If (IsIsymb @@ s) (Pure "e") (Pure s) ):}.:kind! Eval (FMapSymbol Isymb2e ('Text "imu"))/Eval (FMapSymbol Isymb2e ('Text "imu")) :: Text = 'Text "emu"fcf-containersCompare the length of type-level text to given Nat and give the Ordering.Example,:kind! Eval (CompareLength ('Text "aamu") 3)1Eval (CompareLength ('Text "aamu") 3) :: Ordering= 'GTfcf-containers3Take all except the last Char from type-level text.Example":kind! Eval (Init ('Text "aamun")))Eval (Init ('Text "aamun")) :: Maybe Text= 'Just ('Text "aamu"):kind! Eval (Init ('Text ""))$Eval (Init ('Text "")) :: Maybe Text = 'Nothingfcf-containers"Get the tail of a type-level text.Example":kind! Eval (Tail ('Text "haamu")))Eval (Tail ('Text "haamu")) :: Maybe Text= 'Just ('Text "aamu"):kind! Eval (Tail ('Text ""))$Eval (Tail ('Text "")) :: Maybe Text = 'Nothingfcf-containers%Get the last Char of type-level text.Example!:kind! Eval (Last ('Text "aamu"))(Eval (Last ('Text "aamu")) :: Maybe Char = 'Just 'u':kind! Eval (Last ('Text ""))$Eval (Last ('Text "")) :: Maybe Char = 'Nothingfcf-containers&Get the first Char of type-level text.Example!:kind! Eval (Head ('Text "aamu"))(Eval (Head ('Text "aamu")) :: Maybe Char = 'Just 'a':kind! Eval (Head ('Text ""))$Eval (Head ('Text "")) :: Maybe Char = 'Nothingfcf-containers'Get the last Char from type-level text.Example$:kind! Eval (Unsnoc ('Text "aamun"))3Eval (Unsnoc ('Text "aamun")) :: Maybe (Text, Char)= 'Just '( 'Text "aamu", 'n'):kind! Eval (Unsnoc ('Text "")).Eval (Unsnoc ('Text "")) :: Maybe (Text, Char) = 'Nothingfcf-containers(Get the first Char from type-level text.Example$:kind! Eval (Uncons ('Text "haamu"))3Eval (Uncons ('Text "haamu")) :: Maybe (Char, Text)= 'Just '('h', 'Text "aamu"):kind! Eval (Uncons ('Text "")).Eval (Uncons ('Text "")) :: Maybe (Char, Text) = 'Nothingfcf-containersAppend two type-level texts.Example.:kind! Eval (Append ('Text "aa") ('Text "mu"))/Eval (Append ('Text "aa") ('Text "mu")) :: Text= 'Text "aamu"fcf-containers-Add a Symbol to the end of a type-level text.Example*:kind! Eval (SnocSymbol ('Text "aam") "u")+Eval (SnocSymbol ('Text "aam") "u") :: Text= 'Text "aamu"fcf-containers+Add a Char to the end of a type-level text.Example$:kind! Eval (Snoc ('Text "aam") 'u')%Eval (Snoc ('Text "aam") 'u') :: Text= 'Text "aamu"fcf-containers3Add a Symbol to the beginning of a type-level text.Example+:kind! Eval (ConsSymbol "h" ('Text "aamu")),Eval (ConsSymbol "h" ('Text "aamu")) :: Text= 'Text "haamu"fcf-containers1Add a Char to the beginning of a type-level text.Example%:kind! Eval (Cons 'h' ('Text "aamu"))&Eval (Cons 'h' ('Text "aamu")) :: Text= 'Text "haamu"fcf-containersLengthExample(:kind! Eval (Length =<< FromSymbol "ab")/Eval (Length =<< FromSymbol "ab") :: TL.Natural= 2fcf-containersNullExample:kind! Eval (Null ('Text "ab")) Eval (Null ('Text "ab")) :: Bool= 'False:kind! Eval (Null =<< Empty)Eval (Null =<< Empty) :: Bool= 'Truefcf-containersUnpackExample*:kind! Eval (Unpack =<< FromSymbol "word")-Eval (Unpack =<< FromSymbol "word") :: Symbol= "word"fcf-containers4Split text to characters and give them as Text list. ):kind! Eval (ToList =<< FromSymbol "abc")Eval (ToList =<< FromSymbol "abc") :: [Text] = '[ 'Text "a", 'Text "b", 'Text "c"]fcf-containers4Split text to characters and give them as Char list. -:kind! Eval (ToCharList =<< FromSymbol "abc")6Eval (ToCharList =<< FromSymbol "abc") :: [Char] = '[a, b, c]fcf-containers#Get the type-level list out of the .Example9:kind! Eval (ToSymbolList =<< FromSymbolList '["a", "b"])>Eval (ToSymbolList =<< FromSymbolList '["a", "b"]) :: [Symbol] = '["a", "b"]fcf-containers6Use FromList to construct a Text from type-level list.Example:kind! Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) Eval (FromSymbolList '["h", "e", "l", "l", "u", "r", "e", "i"]) :: Text = 'Text "hellurei"fcf-containers FromSymbolExample$:kind! Eval (FromSymbol "some text")%Eval (FromSymbol "some text") :: Text= 'Text "some text"fcf-containers Singleton:kind! Eval (Singleton 'a')Eval (Singleton 'a') :: Text = 'Text "a"fcf-containersEmptyExample:kind! (Eval Empty :: Text)(Eval Empty :: Text) :: Text = 'Text ""+See also the other examples in this module.fcf-containers is a data structure, that is, a list to hold type-level symbols of length one.Monad definitions(c) gspia 2020-BSDgspia Safe-Inferred !01Pfcf-containersAn example implementing=sumM xs ys = do x <- xs y <- ys return (x + y)or3sumM xs ys = xs >>= (x -> ys >>= (y -> pure (x+y)))Note the use of helper functions. This is a bit awkward, a type level lambda would be nice.fcf-containersPart of an examplefcf-containersPart of an examplefcf-containersFor the example. Turn an input number to list of two numbers of a bit larger numbers.fcf-containers%For Applicative documentation examplefcf-containers%For Applicative documentation examplefcf-containersHelper for [] traversefcf-containers Helper for fcf-containers'Helper for the [] applicative instance.fcf-containers5Needed by LiftA5 instance to partially apply functionfcf-containers5Needed by LiftA4 instance to partially apply functionfcf-containers5Needed by LiftA3 instance to partially apply functionfcf-containers5Needed by LiftA2 instance to partially apply functionfcf-containers'Id function correspondes to term level  -function.fcf-containersSequenceExample):kind! Eval (Sequence ('Just ('Right 5)))>Eval (Sequence ('Just ('Right 5))) :: Either a (Maybe Natural)= 'Right ('Just 5)4:kind! Eval (Sequence '[ 'Just 3, 'Just 5, 'Just 7])Eval (Sequence '[ 'Just 3, 'Just 5, 'Just 7]) :: Maybe [Natural]= 'Just '[3, 5, 7]5:kind! Eval (Sequence '[ 'Just 3, 'Nothing, 'Just 7])Eval (Sequence '[ 'Just 3, 'Nothing, 'Just 7]) :: Maybe [Natural] = 'Nothing):kind! Eval (Sequence '[ '[1,2], '[3,4]])1Eval (Sequence '[ '[1,2], '[3,4]]) :: [[Natural]](= '[ '[1, 3], '[1, 4], '[2, 3], '[2, 4]]fcf-containersTraverseExample,:kind! Eval (Traverse Id '[ '[1,2], '[3,4]])4Eval (Traverse Id '[ '[1,2], '[3,4]]) :: [[Natural]](= '[ '[1, 3], '[1, 4], '[2, 3], '[2, 4]]fcf-containersFoldlMExample,import GHC.TypeLits as TL (Symbol, type (-))8data Lambda :: Nat -> Nat -> Exp (Either Symbol Natural)type instance Eval (Lambda a b) = If (Eval (a >= b)) ('Right (a TL.- b)) ('Left "Nat cannot be negative")&:kind! Eval (FoldlM Lambda 5 '[1,1,1])8Eval (FoldlM Lambda 5 '[1,1,1]) :: Either Symbol Natural = 'Right 2&:kind! Eval (FoldlM Lambda 5 '[1,4,1])8Eval (FoldlM Lambda 5 '[1,4,1]) :: Either Symbol Natural = 'Left "Nat cannot be negative"fcf-containersForM = Flip MapMfcf-containersMapMExample=:kind! Eval (MapM (ConstFn '[ 'True, 'False]) '["a","b","c"])Eval (MapM (ConstFn '[ 'True, 'False]) '["a","b","c"]) :: [[Bool]]7= '[ '[ 'True, 'True, 'True], '[ 'True, 'True, 'False],9 '[ 'True, 'False, 'True], '[ 'True, 'False, 'False],9 '[ 'False, 'True, 'True], '[ 'False, 'True, 'False],; '[ 'False, 'False, 'True], '[ 'False, 'False, 'False]]fcf-containersType level >> Example!:kind! Eval ( 'Just 1 >> 'Just 2)+Eval ( 'Just 1 >> 'Just 2) :: Maybe Natural = 'Just 2":kind! Eval ( 'Nothing >> 'Just 2),Eval ( 'Nothing >> 'Just 2) :: Maybe Natural = 'Nothingfcf-containers6Type level Bind corresponding to the value level bind  operator. Note that name (>>=) clashes with the definition given at Fcf.Combinators.(>>=). (It doesn't export it yet, though.)Monads that we define include:Identity[]MaybeEither(,)(,,)(,,,)ExampleExample: double the length of the input list and increase the numbers at the same time.!:kind! Eval ('[5,6,7] >>= Plus2M)'Eval ('[5,6,7] >>= Plus2M) :: [Natural]= '[7, 8, 8, 9, 9, 10]/:kind! Eval (XsPlusYsMonadic '[1,2,3] '[4,5,6])5Eval (XsPlusYsMonadic '[1,2,3] '[4,5,6]) :: [Natural]= '[5, 6, 7, 6, 7, 8, 7, 8, 9]fcf-containersType level LiftA5.fcf-containersType level LiftA4.fcf-containersType level LiftA3.Example0:kind! Eval (LiftA3 Tuple3 '[1,2] '[3,4] '[5,6])Eval (LiftA3 Tuple3 '[1,2] '[3,4] '[5,6]) :: [(Natural, Natural,8 Natural)]= '[ '(1, 3, 5), '(1, 3, 6), '(1, 4, 5), '(1, 4, 6), '(2, 3, 5),( '(2, 3, 6), '(2, 4, 5), '(2, 4, 6)]:kind! Eval (LiftA3 Tuple3 ('Right 5) ('Right 6) ('Left "fail"))Eval (LiftA3 Tuple3 ('Right 5) ('Right 6) ('Left "fail")) :: Either TL.Symbol (Natural, Natural, c)= 'Left "fail"fcf-containersType level LiftA2.Example*:kind! Eval (LiftA2 (Fcf.+) '[1,2] '[3,4])0Eval (LiftA2 (Fcf.+) '[1,2] '[3,4]) :: [Natural]= '[4, 5, 5, 6]fcf-containers( *!) corresponds to the value level . Note that this clashes with the definition given at Fcf.Combinators.(( *)).$Applicatives that we define include:Identity[]MaybeEither(,)(,,)(,,,)Example-:kind! Eval ('Identity Plus2 <*> 'Identity 5):Eval ('Identity Plus2 <*> 'Identity 5) :: Identity Natural = 'Identity 79:kind! Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[4,5,6,7])?Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[4,5,6,7]) :: [Natural]= '[5, 6, 7, 8, 40, 50, 60, 70]2:kind! Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[])8Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[]) :: [Natural]= '[]#:kind! Eval ( (<*>) '[] '[4,5,6,7])#Eval ( (<*>) '[] '[4,5,6,7]) :: [b]= '[]fcf-containersReturn corresponds to the  at Monad or  of Applicative.:kind! Eval (Return 1) :: Maybe Nat :kind! Eval (Return 1) :: Either Symbol Natfcf-containersFor tuples, the  constraint determines how the first values merge. For example, Symbols concatenate:::kind! Eval ('("hello", (Fcf.+) 15) <*> '("world!", 2002))Eval ('("hello", (Fcf.+) 15) <*> '("world!", 2002)) :: (TL.Symbol, Natural)= '("helloworld!", 2017).Tree data-structure for type-level programming(c) gspia 2020-BSDgspia Safe-Inferred !01W fcf-containersGet the levels from a .Example:kind! Eval (Levels ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]]))Eval (Levels ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]])) :: [[TL.Natural]]"= '[ '[1], '[2, 5], '[3, 6], '[4]]fcf-containersGet the forests from a list of s.fcf-containers"Get the root nodes from a list of s.fcf-containersGet the forest from a .fcf-containersGet the root node from a .fcf-containers Flatten a .Example:kind! Eval (Flatten ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]]))Eval (Flatten ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]])) :: [TL.Natural]= '[1, 2, 3, 4, 5, 6]fcf-containers Unfold for a .fcf-containers Unfold for a .Example(data BuildNode :: Nat -> Exp (Nat,[Nat]):{$ type instance Eval (BuildNode x) =( If (Eval ((2 TL.* x TL.+ 1) >= 8)) '(x, '[])/ '(x, '[2 TL.* x, (2 TL.* x) TL.+ 1 ]):}$:kind! Eval (UnfoldTree BuildNode 1)0Eval (UnfoldTree BuildNode 1) :: Tree TL.Natural= 'Node 1, '[ 'Node 2 '[ 'Node 4 '[], 'Node 5 '[]],, 'Node 3 '[ 'Node 6 '[], 'Node 7 '[]]]fcf-containersFold a type-level .fcf-containersSame as in containers, except not used for any term-level computation in this module.fcf-containersSame as in containers, except not used for any term-level computation in this module.List helpers / utils(c) gspia 2023-BSDgspia Safe-Inferred!01Zfcf-containersReflect a list of Nats [Int]afun = natVals @n Proxy:}afun [1,2,3,4]fcf-containersText instance.Example!import qualified Data.Text as Txt:{4afun :: forall r. (r ~ 'FTxt.Text "hmm") => Txt.Textafun = fromType (Proxy @r):}afun"hmm"Tree-structures working with Algebras, ColAlgebras, and other stuff(c) gspia 2020-BSDgspia Safe-Inferred !01hfcf-containersEfficient Fibonacci type-level function (from Recursion Schemes by example, Tim Williams). Compare this to .Example:kind! Eval (FibHisto 100)!Eval (FibHisto 100) :: TL.Natural= 354224848179261915075fcf-containersEfficient Fibonacci algebra from Recursion Schemes by example, Tim Williams.fcf-containers=We want to be able to build NatF Fix-structures out of Nat's.fcf-containersA NatF functor that can be used with different morphisms. This tree-module is probably a wrong place to this one. Now it is here for the Fibonacci example.fcf-containers=A kind of foldable sum class. Pun may or may not be intended.fcf-containersBTreeF is a btree functor. At the moment, it is used to build sorting algorithms.fcf-containers#Fibonaccis with Hylo, not efficientExample:kind! Eval (FibHylo 10)Eval (FibHylo 10) :: TL.Natural= 55fcf-containersCoAlgebra for the Fib-function.fcf-containersCoAlgebra to build TreeF's. This is an example from containers-package. See  and example in there.:kind! Eval (Ana BuildNodeCoA 1) :kind! Eval (Hylo CountNodesAlg BuildNodeCoA 1)fcf-containers.Size of the Tree is the number of nodes in it.ExampleSize is defined as % Cata CountNodesAlg =<< TreeToFix tr % and can be used with the following.(data BuildNode :: Nat -> Exp (Nat,[Nat]):{$ type instance Eval (BuildNode x) =( If (Eval ((2 TL.* x TL.+ 1) >= 8)) '(x, '[])0 '(x, '[ 2 TL.* x, (2 TL.* x) TL.+ 1 ]):}-:kind! Eval (Size =<< UnfoldTree BuildNode 1)4Eval (Size =<< UnfoldTree BuildNode 1) :: TL.Natural= 7fcf-containersCount the nodes of TreeF. See the  for an example.fcf-containers'Sum the nodes of TreeF containing Nats.See the implementation of Fib for an example.fcf-containersA function to transform a Tree into fixed structure that can be used by Cata and Ana.See the implementation of  for an example.fcf-containers is functor for s. ! has Map-instance (on structure).fcf-containersBTreeF is a functorfcf-containersInstances to make TreeF to be a foldable sum. After this one, we can write the  example.fcf-containersSizes example from Recursion Schemes by example, Tim Williams. This annotes each node with the size of its subtree.Example*:kind! Eval (Sizes =<< Ana BuildNodeCoA 1)*Eval (Sizes =<< Ana BuildNodeCoA 1) :: Fix (AnnF (TreeF TL.Natural) TL.Natural)= 'Fix ('AnnF '( 'NodeF 1 '[ 'Fix ('AnnF '( 'NodeF 2= '[ 'Fix ('AnnF '( 'NodeF 4 '[], 1)),> 'Fix ('AnnF '( 'NodeF 5 '[], 1))], 3)), 'Fix ('AnnF '( 'NodeF 3= '[ 'Fix ('AnnF '( 'NodeF 6 '[], 1)),> 'Fix ('AnnF '( 'NodeF 7 '[], 1))], 3))], 7))fcf-containers?NatF has to have functor-instances so that morphisms will work.+Type-level sorting algorithms and utilities(c) gspia 2020-BSDgspia Safe-Inferred !01lefcf-containers%Qsort - give the comparison function a -> a -> Exp Bool comparing your list elements and then Qsort will order the list.Example*:kind! Eval (Qsort (N.<) '[5,3,1,9,4,6,3])3Eval (Qsort (N.<) '[5,3,1,9,4,6,3]) :: [TL.Natural]= '[1, 3, 3, 4, 5, 6, 9]7:kind! Eval (Qsort (S.<) '[ "bb", "e", "a", "e", "d" ])?@ABCDEFGHIJKLMNOPQBRSTUVWXYZ[\]^_`,abcdefghijklmnopqrstuvww ^ _ ` , a b c d x f g h i j k l m n o p q r s t u v y y , t z h i j { | k l m n q s u v } } ~            B R S T U  W X Y Z [             ,   l,tuvl,tuvl,tuvCEFGMNPkfcf-containers-0.8.1-inplaceFcf.Alg.Morphism Fcf.Alg.List Fcf.Alg.Nat Fcf.Alg.OtherFcf.Data.Bitree Fcf.Data.CharFcf.Data.List.Utils Fcf.Data.MapCFcf.Data.NatMap Fcf.Data.SetFcf.Data.SymbolFcf.Alg.SymbolFcf.Data.Text.Internal Fcf.Data.TextFcf.Data.OldTextFcf.Data.TupleFcf.Data.NewTextFcf.Control.Monad Fcf.Data.TreeFcf.Data.Reflect Fcf.Alg.Tree Fcf.Alg.SortSecondFirstHistoHistoAlg SynthesizeSynthAlg AnnConstrStripAttrAnnAnnFParaFanoutHyloAnaCataRAlgebra CoAlgebraAlgebraFixEqualToListMToNMToNHelpSumRunInc ListRunAlgNumIterEvensEvensAlg EvensStrip SlidingAlgSlidingDedupAlg ListToParaFixProdAlgSumAlgLenAlg ListToFixListFConsFNilF/===IdPairMaybeToMaybePairGetRootsGetRootFlatten ExampleTree4 ExampleTree3 ExampleTree2 ExampleTree1 CountSizeHelpFoldTreeTreeLeafNode $fShowTree><>=<=CharOrdIsDigit IsSpaceDelimIsTab IsNewLineIsSpace MaybeToListFoldl Partition FilterWithKeyFilterAssocsKeysElemsFoldr MapWithKeyMapDisjoint Intersection DifferenceUnionSizeNull NotMemberMemberLookupAdjustDelete InsertWithInsertFromList SingletonEmptyMapC NatMapWithKeyNatMapPowerSetIsProperSubsetOf IsSubsetOfSet ConcatCharsConcat CharToSymbol ToCharList HandlePair NatToChar CharToNat UnconsSymbolConsCharCmpChar CmpSymbol AppendSymbol SymbolOrd IntercalateAppendCharsLookup2LookupAToList2ToList1Head1UnconsToListAHeadA ToSymbol2Head2 LookupTablechars IsInfixOf IsSuffixOf IsPrefixOfUnwordsUnlinesWordsLinesSplitSplitOn DropAround DropWhileEnd DropWhile TakeWhileEnd TakeWhileDropEndDropTakeEndTakeAllAny FConcatMapReplaceReverse IntersperseFMap CompareLengthInitTailHeadUnsnocSnocConsLengthToSymbol ToSymbolListFromSymbolListTextTuple5Tuple4Tuple3Tuple2SwapDropAroundSymbolDropWhileEndSymbolTakeWhileEndSymbolTakeWhileSymbol AllSymbol AnySymbol ConcatMapCS ConcatMapConcatMapSymbolIntersperseSymbolFMapT FMapSymbolLast SnocSymbol ConsSymbolUnpack FromSymbolXsPlusYsMonadicXPlusYs PureXPlusYPlus2MPlus2Plus1 ConsHelper FoldlMHelperStar_App5App4App3App2SequenceTraverseFoldlMForMMapM>>>>=LiftA5LiftA4LiftA3LiftA2<*>ReturnLevels SubFLevels GetForests GetForest UnfoldForest UnfoldTreeStarTxExTr2ExT1rForestKnownValfromType KnownNatsnatVals $fKnownNats: $fKnownNats[]$fKnownVal(,,,,)(,,,,)(,,,,)$fKnownVal(,,,)(,,,)(,,,)$fKnownVal(,,)(,,)(,,)$fKnownVal(,)(,)(,)$fKnownValMaybeMaybeNothing$fKnownValMaybeMaybeJust$fKnownValEitherEitherRight$fKnownValEitherEitherLeft$fKnownValSetSetSet$fKnownValMapCMapMapC$fKnownValNatMapIntMapNatMap$fKnownValTreeTreeNode$fKnownVal[][]:$fKnownVal[][][]$fKnownValTextstrText$fKnownValSymbolstrs$fKnownValBoolBoolFalse$fKnownValBoolBoolTrue$fKnownValNaturalanFibHisto FibAlgebraRecNTFNatToFixNatFSuccZeroSizesFSumBTreeFBEmptyFBNodeFFibHyloBuildFibTreeCoA BuildNodeCoA CountNodesAlg SumNodesAlg TreeToFixTreeFNodeFPartCmpQsortInordPartHlp NatListOrd SymbolListOrdNatOrdListOrdListCmp ListCmpFnd SplitLoop SplitTakeSOLoopSOTake SplitSymbolDropWhileSymbolbaseGHC.BaseidreturnpureD:R:Eval(,)<*>MonoidD:R:EvalBTreeFMap0D:R:EvalNaturalFSum0D:R:EvalFixSizesD:R:EvalNatFMap0