úΡüž F      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEunportable (GADTs, Rank2Types) experimentalbyorgey@gmail.comFAInternal representation of a split list that tracks which pieces  are delimiters and which aren't. "Tag chunks as delimiters or text. 8What to do with a blank chunk at either end of the list 9 (i.e. when the list begins or ends with a delimiter). 1What to do with multiple consecutive delimiters? Insert blank chunks  between consecutive  delimiters. "Condense into a single delimiter. What to do with delimiters? Keep delimiters in the output, ) appending them to the previous chunk. Keep delimiters in the output, $ prepending them to the following  chunk. #Keep delimiters as separate chunks  of the output. !Drop delimiters from the output. @A delimiter can either be a predicate on elements, or a list of , elements to be matched as a subsequence. A splitting strategy. What delimiter to split on !What to do with delimiters (drop ! from output, keep as separate % elements in output, or merge with ! previous or following chunks) What to do with multiple  consecutive delimiters Drop an initial blank? Drop a final blank? >The default splitting strategy: keep delimiters in the output  as separate chunks, don' t condense multiple consecutive = delimiters into one, keep initial and final blank chunks. 8 Default delimiter is the constantly false predicate.  Note that " should normally not be used; use  +, ,, or - instead, which are the same as  the % with just the delimiter overridden. The % strategy with any delimiter gives a E maximally information-preserving splitting strategy, in the sense  that (a) taking the F# of the output yields the original B list, and (b) given only the output list, we can reconstruct a  6 which would produce the same output list again given E the original input list. This default strategy can be overridden 5 to allow discarding various sorts of information. @Try to match a delimiter at the start of a list, either failing H or decomposing the list into the portion which matched the delimiter  and the remainder. Untag a . Test whether a  is a delimiter. Test whether a  is text. Standard build function. 8Given a delimiter to use, split a list into an internal B representation with chunks tagged as delimiters or text. This . transformation is lossless; in particular, G   ( d l) == l. BGiven a split list in the internal tagged representation, produce C a new internal tagged representation corresponding to the final : output, according to the strategy defined by the given  . !Drop delimiters if the   is . "9Condense multiple consecutive delimiters into one if the   is  . #BInsert blank chunks between any remaining consecutive delimiters, A and at the beginning or end if the first or last element is a  delimiter. $4Insert blank chunks between consecutive delimiters. %7Merge delimiters into adjacent chunks according to the  . &=Merge delimiters with adjacent chunks to the right (yes, that's ? not a typo: the delimiters should end up on the left of the ; chunks, so they are merged with chunks to their right). '3Merge delimiters with adjacent chunks to the left. (3Drop an initial blank chunk according to the given . )0Drop a final blank chunk according to the given . *ASplit a list according to the given splitting strategy. This is  how to "run" a % that has been built using the other  combinators. +9A splitting strategy that splits on any one of the given  elements. For example: R split (oneOf "xyz") "aazbxyzcxd" == ["aa","z","b","x","","y","","z","c","x","d"] ,?A splitting strategy that splits on the given list, when it is 6 encountered as an exact subsequence. For example:  > split (onSublist "xyz") "aazbxyzcxd" == ["aazb","xyz","cxd"] ?Note that splitting on the empty list is a special case, which K splits just before every element of the list being split. For example:  9 split (onSublist "") "abc" == ["","","a","","b","","c"] G split (dropDelims . dropBlanks $ onSublist "") "abc" == ["a","b","c"] BHowever, if you want to break a list into singleton elements like " this, you are better off using C 1, or better yet,  H (:[]). -BA splitting strategy that splits on any elements that satisfy the " given predicate. For example: C split (whenElt (<0)) [2,4,-3,6,-9,1] == [[2,4],[-3],[6],[-9],[1]] .8Drop delimiters from the output (the default is to keep  them). For example, 8 split (oneOf ":") "a:b:c" == ["a", ":", "b", ":", "c"] ; split (dropDelims $ oneOf ":") "a:b:c" == ["a", "b", "c"] /=Keep delimiters in the output by prepending them to adjacent  chunks. For example: Q split (keepDelimsL $ oneOf "xyz") "aazbxyzcxd" == ["aa","zb","x","y","zc","xd"] 0<Keep delimiters in the output by appending them to adjacent  chunks. For example: Q split (keepDelimsR $ oneOf "xyz") "aazbxyzcxd" == ["aaz","bx","y","z","cx","d"] 1ACondense multiple consecutive delimiters into one. For example: Q split (condense $ oneOf "xyz") "aazbxyzcxd" == ["aa","z","b","xyz","c","x","d"] K split (dropDelims $ oneOf "xyz") "aazbxyzcxd" == ["aa","b","","","c","d"] P split (condense . dropDelims $ oneOf "xyz") "aazbxyzcxd" == ["aa","b","c","d"] 2Don'8t generate a blank chunk if there is a delimiter at the  beginning. For example: 2 split (oneOf ":") ":a:b" == ["",":","a",":","b"] ? split (dropInitBlank $ oneOf ":") ":a:b" == [":","a",":","b"] 3Don'=t generate a blank chunk if there is a delimiter at the end.  For example: 2 split (oneOf ":") "a:b:" == ["a",":","b",":",""] @ split (dropFinalBlank $ oneOf ":") "a:b:" == ["a",":","b",":"] 46Drop all blank chunks from the output. Equivalent to  2 . 3 . 1. For example: J split (oneOf ":") "::b:::a" == ["",":","",":","b",":","",":","",":","a"] B split (dropBlanks $ oneOf ":") "::b:::a" == ["::","b",":::","a"] 5>Make a strategy that splits a list into chunks that all start ; with the given subsequence (except possibly the first).  Equivalent to 2 . / . ,.  For example: w split (startsWith "app") "applyappicativeapplaudapproachapple" == ["apply","appicative","applaud","approach","apple"] 6>Make a strategy that splits a list into chunks that all start ? with one of the given elements (except possibly the first).  Equivalent to 2 . / . +. For  example: ` split (startsWithOneOf ['A'..'Z']) "ACamelCaseIdentifier" == ["A","Camel","Case","Identifier"] 7AMake a strategy that splits a list into chunks that all end with C the given subsequence, except possibly the last. Equivalent to  3 . 0 . ,. For example: Y split (endsWith "ly") "happilyslowlygnarlylily" == ["happily","slowly","gnarly","lily"] 8AMake a strategy that splits a list into chunks that all end with D one of the given elements, except possibly the last. Equivalent  to 3 . 0 . +. For example: q split (condense $ endsWithOneOf ".,?! ") "Hi, there! How are you?" == ["Hi, ","there! ","How ","are ","you?"] 93Split on any of the given elements. Equivalent to *  . . . +. For example: E splitOneOf ";.," "foo,bar;baz.glurk" == ["foo","bar","baz","glurk"] :+Split on the given sublist. Equivalent to *  . . . ,. For example: < splitOn ".." "a..b...c....d.." == ["a","b",".c","","d",""] ;ASplit on elements satisfying the given predicate. Equivalent to  * . . . -. For example: ; splitWhen (<0) [1,3,-4,5,7,-9,0,2] == [[1,3],[5,7],[0,2]] <A synonym for :. =A synonym for 9. >7Split into chunks terminated by the given subsequence.  Equivalent to * . 3 . .  . ,. For example:  1 endBy ";" "foo;bar;baz;" == ["foo","bar","baz"] Note also that the I function from  Data.List is equivalent  to > "\n". ?;Split into chunks terminated by one of the given elements.  Equivalent to * . 3 . . . +. @A synonym for < / :. +Note that this is the right inverse of the  intercalate function  from  Data.List , that is,  intercalate x . @ x  == J. It is also the case that @ x  .  intercalate x is idempotent. @ x  .  intercalate x- is the identity on certain lists, but it is B tricky to state the precise conditions under which this holds. . (For example, it is not enough to say that x does not occur in B any elements of the input list. Working out why is left as an  exercise for the reader.) A>Split into words, with word boundaries indicated by the given  predicate. Satisfies words === wordsBy isSpace; equivalent to  )split . dropBlanks . dropDelims . whenElt. For example: < wordsBy (=='x') "dogxxxcatxbirdxx" == ["dog","cat","bird"] B>Split into lines, with line boundaries indicated by the given  predicate. Satisfies lines === linesBy (=='\n'); equivalent to  -split . dropFinalBlank . dropDelims . whenElt. For example: E linesBy (=='x') "dogxxxcatxbirdxx" == ["dog","","","cat","bird",""] CC n/ splits a list into length-n pieces. The last  piece will be shorter if n& does not evenly divide the length of  the list. If n <= 0, C n l returns an infinite list  of empty lists. DA common synonym for C. E<Split a list into chunks of the given lengths. For example:  : splitPlaces [2,3,4] [1..20] == [[1,2],[3,4,5],[6,7,8,9]] 9 splitPlaces [4,9] [1..10] == [[1,2,3,4],[5,6,7,8,9,10]] The behavior of E ls xs when K ls /= L xs can 9 be inferred from the above examples and the fact that E  is total. F  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEunportable (GADTs, Rank2Types) experimental Brent Yorgey <byorgey@gmail.com>*+,-./0123456789:;<=>?@ABCDE:9;<=>?@ABCDE*+,-./012345678M      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJHIKHLMHNOHLPHNQHIRS split-0.1.1Data.List.Split.InternalsData.List.Split SplitListChunkTextDelim EndPolicy KeepBlank DropBlankCondensePolicyKeepBlankFieldsCondense DelimPolicy KeepRightKeepLeftKeepDrop Delimiter DelimSublist DelimEltPredSplitter delimiter delimPolicycondensePolicyinitBlankPolicyfinalBlankPolicydefaultSplitter matchDelimfromElemisDelimisTextbuild splitInternal postProcessdoDrop doCondense insertBlanks insertBlanks'doMerge mergeLeft mergeRight dropInitial dropFinalsplitoneOf onSublistwhenElt dropDelims keepDelimsL keepDelimsRcondense dropInitBlankdropFinalBlank dropBlanks startsWithstartsWithOneOfendsWith endsWithOneOf splitOneOfsplitOn splitWhensepBy sepByOneOfendBy endByOneOf unintercalatewordsBylinesBy splitEverychunk splitPlacesbaseGHC.Listconcat concatMapGHC.Basemap Data.Listlinesidsumlength