|,C      !"#$%&'()*+,-./0123456789:;<=>?@ABUnsafeDC Herbert Valerio Riedel 2017BSD3 hvr@gnu.orgstableUnsafe  %DFKQTV34DUnicode Code-pointKeeping it as a E' is more convenient for bit-ops and FFIFByte offset (or size) in bytesThis currently wraps an GJ because this is what GHC's primops currently use for byte offsets/sizes.,A compact representation of Unicode strings.A > value is a sequence of Unicode scalar values, as defined in  =http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf#page=3503.9, definition D76 of the Unicode 5.2 standard; This means that a J is a list of (scalar) Unicode code-points (i.e. code-points in the range '[U+00 .. U+D7FF] "* [U+E000 .. U+10FFFF]).This type relates to H as I relates to JG by providing a more compact type. Please consult the documentation of Data.ByteString.Short for more information.Currently, a boxed unshared H has a memory footprint of 6 words (i.e. 48 bytes on 64-bit systems) plus 2 or 4 bytes per code-point (due to the internal UTF-16 representation). Each H0 value which can share its payload with another H, requires only 4 words additionally. Unlike J, H use unpinned memory.(In comparison, the footprint of a boxed  is only 4 words (i.e. 32 bytes on 64-bit systems) plus 1, 2, 3, or 4 bytes per code-point (due to the internal UTF-8 representation). It can be shown that for realistic data  http://utf8everywhere.org/#asian-UTF-16 has a space overhead of 50% over UTF-8.\mathcal{O}(1) Test whether a  is empty.null ""Truenull (singleton c) == Falsenull t == (length t == 0)\mathcal{O}(n). Count the number of Unicode code-points in a .length "abcd "5 length ""0 length t >= 0\mathcal{O}(n) Test whether C contains only ASCII code-points (i.e. only U+0000 through U+007F).$This is a more efficient version of  . isAscii ""TrueisAscii "abc\NUL"TrueisAscii "abcd "FalseisAscii t == all (< '\x80') t\mathcal{O}(n) Test whether all code points in  satisfy a predicate.all (const False) ""Trueall (> 'c') "abcdabcd"Falseall (/= 'c') "abdabd"True\mathcal{O}(n)# Return the left-most codepoint in $ that satisfies the given predicate.find (> 'b') "abcdabcd"Just 'c'find (> 'b') "ababab"Nothing\mathcal{O}(n)0 Return the index of the left-most codepoint in $ that satisfies the given predicate.findIndex (> 'b') "abcdabcdef"Just 2findIndex (> 'b') "ababab"Nothing,(indexMaybe t =<< findIndex p t) == find p t\mathcal{O}(n) Split M into longest prefix satisfying the given predicate and the remaining suffix.span (< 'c') "abcdabcd"("ab","cdabcd")%fst (span p t) <> snd (span p t) == t\mathcal{O}(n) Split M into longest suffix satisfying the given predicate and the preceding prefix.spanEnd (> 'c') "abcdabcd"("abcdabc","d")+fst (spanEnd p t) <> snd (spanEnd p t) == t \mathcal{O}(0) Converts to UTF-8 encoded IGThis operation has effectively no overhead, as it's currently merely a newtype-cast. \mathcal{O}(n) Converts to UTF-8 encoded J  Construct a K that encodes  as UTF-8. \mathcal{O}(n) Convert to L(fromString . toString) t == tNote: See documentation of  for why (  . ) is not an identity function. \mathcal{O}(n) Reduces the characters of the Z with the binary operator and an initial in forward direction (i.e. from left to right).foldl (\_ _ -> True) False ""False"foldl (\s c -> c : s) ['.'] "abcd""dcba."\mathcal{O}(n) Reduces the characters of the  with the binary operator.foldl1 max "abcdcba"'d'foldl1 const "abcd"'a'foldl1 (flip const) "abcd"'d'Note: Will throw an M% exception if index is out of bounds.\mathcal{O}(n) Strict version of  .\mathcal{O}(n) Strict version of .\mathcal{O}(n) Reduces the characters of the Z with the binary operator and an initial in reverse direction (i.e. from right to left).foldr (\_ _ -> True) False ""Falsefoldr (:) ['.'] "abcd""abcd."\mathcal{O}(n) Reduces the characters of the  with the binary operator.foldr1 max "abcdcba"'d'foldr1 const "abcd"'a'foldr1 (flip const) "abcd"'d'Note: Will throw an M% exception if index is out of bounds.\mathcal{O}(n) Convert to H(fromText . toText) t == t(toText . fromText) t == tThis is currently not \mathcal{O}(1) because currently H@ uses UTF-16 as its internal representation. In the event that HM will change its internal representation to UTF-8 this operation will become \mathcal{O}(1).\mathcal{O}(n) Construct/pack from L fromString []""fromString ['a','b','c']"abc"OfromString ['\55295','\55296','\57343','\57344'] -- U+D7FF U+D800 U+DFFF U+E000"\55295\65533\65533\57344"Note: This function is total because it replaces the (invalid) code-points U+D800 through U+DFFF with the replacement character U+FFFD.\mathcal{O}(n) Construct  from HThis is currently not \mathcal{O}(1) because currently H@ uses UTF-16 as its internal representation. In the event that HM will change its internal representation to UTF-8 this operation will become \mathcal{O}(1).\mathcal{O}(n) Construct  from UTF-8 encoded I&This operation doesn't copy the input I but it cannot be \mathcal{O}(1)0 because we need to validate the UTF-8 encoding.Returns N# in case of invalid UTF-8 encoding.CfromShortByteString "\x00\x38\xF0\x90\x8C\x9A" -- U+00 U+38 U+1031AJust "\NUL8\66330";fromShortByteString "\xC0\x80" -- invalid denormalised U+00NothingDfromShortByteString "\xED\xA0\x80" -- U+D800 (non-scalar code-point)Nothing2fromShortByteString "\xF4\x8f\xbf\xbf" -- U+10FFFFJust "\1114111"<fromShortByteString "\xF4\x90\x80\x80" -- U+110000 (invalid)Nothing3fromShortByteString (toShortByteString t) == Just t\mathcal{O}(0) Construct  from UTF-8 encoded IGThis operation has effectively no overhead, as it's currently merely a newtype-cast.WARNING: Unlike the safe ! conversion, this conversion is unsafeC as it doesn't validate the well-formedness of the UTF-8 encoding.\mathcal{O}(n) Construct  from UTF-8 encoded J- accepts (or rejects) the same input data as .Returns N# in case of invalid UTF-8 encoding.\mathcal{O}(n) Construct  from UTF-8 encoded JThis operation is \mathcal{O}(n) because the J& needs to be copied into an unpinned O.WARNING: Unlike the safe ! conversion, this conversion is unsafeC as it doesn't validate the well-formedness of the UTF-8 encoding.\mathcal{O}(n) Lookup i-th code-point in .Returns N if out of bounds.$indexMaybe (singleton c) 0 == Just c%indexMaybe t 0 == fmap fst (uncons t)indexMaybe mempty i == Nothing\mathcal{O}(n) Lookup i-th code-point from the end of .Returns N if out of bounds.'indexEndMaybe (singleton c) 0 == Just c(indexEndMaybe t 0 == fmap snd (unsnoc t)!indexEndMaybe mempty i == Nothing\mathcal{O}(n) Split  into two halves.'splitAtOfs n t returns a pair of  with the following properties:6length (fst (splitAt n t)) == min (length t) (max 0 n)+fst (splitAt n t) <> snd (splitAt n t) == tsplitAt 2 "abcdef" ("ab","cdef")splitAt 10 "abcdef" ("abcdef","")splitAt (-1) "abcdef" ("","abcdef")\mathcal{O}(n) Split  into two halves. n t returns a pair of  with the following properties:9length (snd (splitAtEnd n t)) == min (length t) (max 0 n)1fst (splitAtEnd n t) <> snd (splitAtEnd n t) == t*splitAtEnd n t == splitAt (length t - n) tsplitAtEnd 2 "abcdef" ("abcd","ef")splitAtEnd 10 "abcdef" ("","abcdef")splitAtEnd (-1) "abcdef" ("abcdef","")\mathcal{O}(n) Inverse operation to +Returns N for empty input .uncons (cons c t) == Just (c,t) uncons ""Nothing uncons "fmap"Just ('f',"map")\mathcal{O}(n) Inverse operation to ,Returns N for empty input .unsnoc (snoc t c) == Just (t,c) unsnoc ""Nothing unsnoc "fmap"Just ("fma",'p') \mathcal{O}(n) Tests whether the first  is a prefix of the second isPrefixOf "ab" "abcdef"TrueisPrefixOf "ac" "abcdef"FalseisPrefixOf "" t == TrueisPrefixOf t t == True!\mathcal{O}(n) Strip prefix from second  argument.Returns N: if first argument is not a prefix of the second argument. stripPrefix "text-" "text-short" Just "short" stripPrefix "test-" "text-short"Nothing"\mathcal{O}(n) Tests whether the first  is a suffix of the second isSuffixOf "ef" "abcdef"TrueisPrefixOf "df" "abcdef"FalseisSuffixOf "" t == TrueisSuffixOf t t == True#\mathcal{O}(n) Strip suffix from second  argument.Returns N: if first argument is not a suffix of the second argument.!stripSuffix "-short" "text-short" Just "text" stripSuffix "-utf8" "text-short"Nothing$\mathcal{O}(n)( Insert character between characters of .intersperse '*' "_""_"intersperse '*' "MASH" "M*A*S*H"%\mathcal{O}(n) Insert  inbetween list of s.intercalate ", " []""intercalate ", " ["foo"]"foo"$intercalate ", " ["foo","bar","doo"]"foo, bar, doo"intercalate "" ts == concat ts&\mathcal{O}(n*m) Replicate a .DA repetition count smaller than 1 results in an empty string result.replicate 3 "jobs!""jobs!jobs!jobs!"replicate 10000 """"replicate 0 "nothing""",length (replicate n t) == max 0 n * length t'\mathcal{O}(n) Reverse characters in .reverse "star live desserts""stressed evil rats"$reverse (singleton c) == singleton creverse (reverse t) == t(\mathcal{O}(n) Remove characters from % which don't satisfy given predicate.Wfilter (`notElem` ['a','e','i','o','u']) "You don't need vowels to convey information!""Y dn't nd vwls t cnvy nfrmtn!"filter (const False) t == ""filter (const True) t == tlength (filter p t) <= length t-filter p t == pack [ c | c <- unpack t, p c ])\mathcal{O}(n)0 Strip characters from the beginning end and of  which satisfy given predicate.)dropAround (== ' ') " white space ""white space"dropAround (> 'a') "bcdefghi"""PConstruct a new  from an existing one by slicingNB: The Q arguments refer to byte-offsets*\mathcal{O}(1) Construct  from single codepoint.singleton c == pack [c]length (singleton c) == 1 singleton 'A'"A"Rmap singleton ['\55295','\55296','\57343','\57344'] -- U+D7FF U+D800 U+DFFF U+E000%["\55295","\65533","\65533","\57344"]Note: This function is total because it replaces the (invalid) code-points U+D800 through U+DFFF with the replacement character U+FFFD.+\mathcal{O}(n) Prepend a character to a .cons c t == singleton c <> t,\mathcal{O}(n)$ Append a character to the ond of a .snoc t c == t <> singleton cRNote: Surrogate pairs ([U+D800 .. U+DFFF],) in string literals are replaced by U+FFFD.This matches the behaviour of IsString instance for H.SNote: Surrogate pairs ([U+D800 .. U+DFFF],) character literals are replaced by U+FFFD.TThe U encoding matches the one for HVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~GNE      !"#$%&'()*+,-./01234L56M789JH: ; !"#$%&'()*+, Herbert Valerio Riedel 2017BSD3 hvr@gnu.orgstableUnsafe Herbert Valerio Riedel 2017BSD3 hvr@gnu.orgstable Trustworthyb-\mathcal{O}(n) Variant of  with negated predicate.break (> 'c') "abcdabcd"("abc","dabcd")break p t == span (not . p) t'fst (break p t) <> snd (break p t) == t.\mathcal{O}(n) Variant of  with negated predicate.breakEnd (< 'c') "abcdabcd"("abcdab","cd")#breakEnd p t == spanEnd (not . p) t-fst (breakEnd p t) <> snd (breakEnd p t) == t/\mathcal{O}(n) Index i-th code-point in .Infix operator alias of "abcdefg" !? 2Just 'c'0\mathcal{O}(n) Test whether any code points in  satisfy a predicate.any (> 'c') "abcdabcd"Trueany (const True) ""Falseany (== 'c') "abdabd"False any p t == not (all (not . p) t)1\mathcal{O}(n) Concatenate two s$This is a type-specialised alias of .append "foo" "bar""foobar".length (append t1 t2) == length t1 + length t22\mathcal{O}(n) Concatenate list of s$This is a type-specialised alias of . concat []""concat ["foo","bar","doo"] "foobardoo"3\mathcal{O}(0) The empty .$This is a type-specialised alias of .empty"" null emptyTrue4\mathcal{O}(n) Construct a  from a list of s.This is an alias for .5\mathcal{O}(n) Convert  into a list of s.This is an alias for  .(pack . unpack) t == t6\mathcal{O}(n)- Take prefix of given length or return whole  if too short.take 3 "abcdef""abc" take 3 "ab""ab"7\mathcal{O}(n)- Take suffix of given length or return whole  if too short.takeEnd 3 "abcdefg""efg"takeEnd 3 "ab""ab"8\mathcal{O}(n)) Take remove prefix of given length from  or return 3  if too short.drop 4 "abcdef""ef" drop 4 "ab"""9\mathcal{O}(n)) Take remove suffix of given length from  or return 3  if too short.drop 4 "abcdefghi""efghi" drop 4 "ab""":\mathcal{O}(n)0 Take longest prefix satisfying given predicate.takeWhile p t == fst (span p t)takeWhile (< 'c') "abcdabcd""ab";\mathcal{O}(n)0 Take longest suffix satisfying given predicate.%takeWhileEnd p t == snd (spanEnd p t) takeWhileEnd (>= 'c') "abcdabcd""cd"<\mathcal{O}(n)2 Remove longest prefix satisfying given predicate.dropWhile p t == snd (span p t)dropWhile (< 'c') "abcdabcd""cdabcd"=\mathcal{O}(n)2 Remove longest suffix satisfying given predicate.%dropWhileEnd p t == fst (spanEnd p t) dropWhileEnd (>= 'c') "abcdabcd""abcdab"9  !"#$%&'()*+,-./0123456789:;<=93*412+,&50 "/6789:;<=)-.!#$%'(     Herbert Valerio Riedel 2018BSD3 hvr@gnu.orgstable Trustworthy>\mathcal{O}(1)( Returns first character of a non-empty  head "abcd"'a'Note: Will throw an M exception for empty 's. Consider using the total functions  or  instead.?\mathcal{O}(n)% Drop first character from non-empty . tail "abcd""bcd"Note: Will throw an M exception for empty 's. Consider using the total functions  or 8 instead.@\mathcal{O}(n)$ Drop last character from non-empty . tail "abcd""bcd"Note: Will throw an M exception for empty 's. Consider using the total functions  or 9 instead.A\mathcal{O}(1)& Return last character from non-empty . last "abcd"'d'Note: Will throw an M exception for empty 's. Consider using the total functions  or  instead.B\mathcal{O}(n) Retrieve i-th character (code-point)index "abcd" 1'b'Note: Will throw an MK exception if index is out of bounds. Consider using the total functions  or  instead.>?@AB>?@AB<      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMJNOPJNQRSTUVWUXYUZ[\]^\_`\]aJKbc\defghijkl\]mJKn\op\qr\st\su\]v\]w\]x\yz\y{\|}\|~\|\|\|\|\|\|\|\|\|\|JJJ\\\\\\\\\\\\\\\\\\\\y\y\y\y\y\y\y\y\y\y\y\y\]\]\]\]\]\]\]\]\\\\\\\\JJJJJJJJ\\\\y\y\\\\\\\\\\\\\\\\y\y\y\y\y\y\\\\\]\]\]\]\]\\\\\\\\\\\\\]\]\]\]\]\]JNJNJNJNJNJN\]\] JN JN JN JN \yJN\\\\q\q\q\q\q\q\q\q\q\q\q\q\ !\"#\ $\ %\&\'\(\)\*\+\,-\,.\,/\,0\12\13\4\5\6\78\9:\y;\y<\y=\y>\y?\y@\A\B\C\D\E\oF\oG\oH\oI\oJ\oK\oL\oM\oN\oO\oP\oQ\oR\oS\TU\sV\sW\X\]Y\]Z\][\]\\]]\]^\]_\]`\_a\_bJcJdJefgtext-short-0.1.2-inplaceData.Text.ShortData.Text.Short.PartialData.Text.Short.UnsafePrimOpsData.Text.Short.Internal Data.CharisAscii ShortTextnulllengthallfind findIndexspanspanEndtoShortByteString toByteString toBuildertoStringfoldlfoldl1foldl'foldl1'foldrfoldr1toText fromStringfromTextfromShortByteStringfromShortByteStringUnsafefromByteStringfromByteStringUnsafe indexMaybe indexEndMaybesplitAt splitAtEndunconsunsnoc isPrefixOf stripPrefix isSuffixOf stripSuffix intersperse intercalate replicatereversefilter dropAround singletonconssnocbreakbreakEnd!?anyappendconcatemptypackunpacktaketakeEnddropdropEnd takeWhile takeWhileEnd dropWhile dropWhileEndheadtailinitlastindexghc-primGHC.PrimcompareByteArrays#CP GHC.TypesWordBInt text-1.2.3.0Data.Text.InternalTextbytestring-0.10.8.2Data.ByteString.Short.InternalShortByteStringData.ByteString.Internal ByteString Data.ByteString.Builder.InternalBuilderbaseGHC.BaseStringGHC.ErrerrorNothing ByteArray#sliceForeign.C.TypesCSize$fIsStringShortText$fIsListShortText$fBinaryShortTextbinary-0.8.5.1Data.Binary.ClassBinary$fPrintfArgShortText++seqGHC.Listzip System.IOprint Data.Tuplefstsnd otherwisemap$GHC.Real fromIntegral realToFracGHC.EnumBoundedminBoundmaxBoundEnumenumFrom enumFromThenenumFromThenTo enumFromTofromEnumtoEnumsuccpred GHC.ClassesEq==/= GHC.FloatFloatingpiexplogsqrt**logBasesincostanasinacosatansinhcoshtanhasinhacoshatanh Fractional fromRational/recipIntegral toIntegerquotremdivmodquotRemdivModMonad>>=>>returnfailFunctorfmap<$GHC.NumNum*+-negate fromIntegerabssignumOrd>=minmax><<=compareGHC.ReadRead readsPrecreadListReal toRational RealFloat floatRadix floatDigits floatRange decodeFloat encodeFloatexponent significand scaleFloatisNaN isInfiniteisDenormalizedisNegativeZeroisIEEEatan2RealFracproperFractiontruncateroundceilingfloorGHC.ShowShow showsPrecshowshowList Applicativepure<*>*><* Data.FoldableFoldablefoldMapsumproductmaximumminimumelemData.Traversable TraversabletraversemapM sequenceAsequence Semigroup<>MonoidmemptymappendmconcatBoolFalseTrueCharDoubleFloat integer-gmpGHC.Integer.TypeIntegerMaybeJustOrderingLTEQGTRationalIO Data.EitherEitherLeftRightreadIOreadLn appendFile writeFilereadFileinteract getContentsgetLinegetCharputStrLnputStrputCharGHC.IO.ExceptionioErrorGHC.IOFilePath userErrorIOErrornotElemorand concatMap sequence_mapM_ Data.OldListunwordswordsunlineslines Text.Readreadreadseitherlex readParenText.ParserCombinators.ReadPReadS Data.Functor<$>lcmgcd^^^oddeven showParen showStringshowCharshowsShowSunzip3unzipzipWith3zipWithzip3!!lookupcyclerepeatiteratescanr1scanrscanl1scanl Data.MaybemaybeuncurrycurrysubtractasTypeOfuntil$!flip.constid=<< undefinederrorWithoutStackTrace&&||not isValidUtf8