#_o       !" # $ % &' ( ) *+,-./01234 56789:; < = > ?@AB C DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                    !"#$%&'()*+,-./01234 5 6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                !"#$%& ' ()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR STUVW X Y Z [\]^_`abcdefghijklmnopqrstuvwxyz{|}~                 !            """"""""""""####### # # # # ###############$$$$ %!%"%#%$%%%&%'%(%)%*%+%,%-%.%/%0%1%2%3&4&5&6&7&8&9':';'<'='>'?'@'A(B(C(D(E(F(G)H)I)J)K)L)M)N)O*P*Q+R+S+T+U+V+W+X+Y+Z+[+\+]+^+_+`+a,b-c-d-e-f-g-h.i.j/k/l/m/n6 \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk44&reludeShorter alias for pure ().pass :: Maybe ()Just ()'reludeNamed version of the  operator, which is 'P but flipped. For chaining applicative operations in forward applications using 0.Just (+ 1) & appliedTo (Just 2)Just 32Just (+) & appliedTo (Just 1) & appliedTo (Just 2)Just 3Nothing & appliedTo (Just 2)Nothing<(')&'<(')&'\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Unsafe/Xk7IQ *+ ,389?@AEPhijSZ[\]^_k! >@?BAIHGFEQE,3Phij>@?SkIHGFE ^Z[BA9*+ ?8@\]! A_\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk<& Dae Dae\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/Xk> !()*+()*+ ! (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk@<=><=>\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkF,reludeRenamed version of 12. identity 1010fmap identity [1,2,3][1,2,3] CD, CD,U(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkH&1lmnopqrutsxwv{zy~}|&1lmnopqrutsxwv{zy~}|U(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkP-relude Alias for  fmap . fmap%. Convenient to work with two nested 1s.negate <<$>> Just [1,2,3]Just [-1,-2,-3].reludeTakes a function in a 1* context and applies it to a normal value.flap (++) "relude" "P" "Prelude"/reludeOperator version of the . function.[(+2), (*3)] ?? 5[7,15]Just (+3) ?? 5Just 8-./-./-4/43U(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkSz*1lmnopqrutsxwv{zy~}|-./\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk\ 0reludeLifted version of 45.exitWith (ExitFailure 3)*** Exception: ExitFailure 3exitWith ExitSuccess*** Exception: ExitSuccess1reludeLifted version of 46. exitFailure*** Exception: ExitFailure 12reludeLifted version of 47. exitSuccess*** Exception: ExitSuccess3reludeLifted version of 48.die "Goodbye!"Goodbye!*** Exception: ExitFailure 101230123\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy/Xki4reludeLifted version of o.ref <- newIORef False:t refref :: IORef Bool5reludeLifted version of p.ref <- newIORef 42 readIORef ref426reludeLifted version of q.ref <- newIORef 42writeIORef ref 43 readIORef ref437reludeLifted version of r.ref <- newIORef 42modifyIORef ref (\a -> a + 6) readIORef ref488reludeLifted version of s.ref <- newIORef 42modifyIORef' ref (\a -> a + 3) readIORef ref459reludeLifted version of t.ref <- newIORef 42(atomicModifyIORef ref (\a -> (a, a + 3))45 readIORef ref42:reludeLifted version of u.ref <- newIORef 42)atomicModifyIORef' ref (\a -> (a, a + 3))45 readIORef ref42;reludeLifted version of v.ref <- newIORef 42atomicWriteIORef ref 45 readIORef ref45 456789:; 9:;78456\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy ,./HUVXk#wrelude)For tracking usage of ordinary list with head-like functions.<reludeO(1)". Extracts the first element of a  list..Actual type of this function is the following: head ::  a -> a Obut it was given a more complex type to provide friendlier compile time errors.head ('a' :| "bcde")'a'head [0..5 :: Int] ...5... 'head' works with 'NonEmpty', not ordinary lists. Possible fix: Replace: [Int] With: NonEmpty Int...: However, you can use 'head' with the ordinary lists./ Apply 'viaNonEmpty' function from relude:% viaNonEmpty head (yourList)- Note, that this will return 'Maybe Int'M therefore it is a safe function unlike 'head' from the standard Prelude...head (Just 'a')...+... 'head' works with 'NonEmpty Char' lists But given: Maybe Char...=reludeO(n). Return all the elements of a " list except the last one element..Actual type of this function is the following: init ::  a -> [a] Obut it was given a more complex type to provide friendlier compile time errors.init ('a' :| "bcde")"abcd"init [0..5 :: Int] ...5... 'init' works with 'NonEmpty', not ordinary lists. Possible fix: Replace: [Int] With: NonEmpty Int...: However, you can use 'init' with the ordinary lists./ Apply 'viaNonEmpty' function from relude:% viaNonEmpty init (yourList)/ Note, that this will return 'Maybe [Int]'M therefore it is a safe function unlike 'init' from the standard Prelude...init (Just 'a')...+... 'init' works with 'NonEmpty Char' lists But given: Maybe Char...>reludeO(n)!. Extracts the last element of a  list..Actual type of this function is the following: last ::  a -> a Obut it was given a more complex type to provide friendlier compile time errors.last ('a' :| "bcde")'e'last [0..5 :: Int] ...5... 'last' works with 'NonEmpty', not ordinary lists. Possible fix: Replace: [Int] With: NonEmpty Int...: However, you can use 'last' with the ordinary lists./ Apply 'viaNonEmpty' function from relude:% viaNonEmpty last (yourList)- Note, that this will return 'Maybe Int'M therefore it is a safe function unlike 'last' from the standard Prelude...last (Just 'a')...+... 'last' works with 'NonEmpty Char' lists But given: Maybe Char...?reludeO(1). Return all the elements of a  list after the head element..Actual type of this function is the following: tail ::  a -> [a] Obut it was given a more complex type to provide friendlier compile time errors.tail ('a' :| "bcde")"bcde"tail [0..5 :: Int] ...5... 'tail' works with 'NonEmpty', not ordinary lists. Possible fix: Replace: [Int] With: NonEmpty Int...: However, you can use 'tail' with the ordinary lists./ Apply 'viaNonEmpty' function from relude:% viaNonEmpty tail (yourList)/ Note, that this will return 'Maybe [Int]'M therefore it is a safe function unlike 'tail' from the standard Prelude...tail (Just 'a')...+... 'tail' works with 'NonEmpty Char' lists But given: Maybe Char...0"#$%&'()*+,-./0123<=>?0"#$%&'()*+,-./0123<=>?\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkU&0:OcdYfg89:;<=     !"%$#U     !"%$#&0:OcdYfg89:;<=\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkV@relude Similar to  but with flipped arguments.readMaybe "True" ?: FalseTruereadMaybe "Tru" ?: FalseFalseAreludeSpecialized version of 9: for O!. It's used for code readability.!Also helps to avoid space leaks:  Ohttp://www.snoyman.com/blog/2017/01/foldable-mapm-maybe-and-recursive-functionsFoldable.mapM_ space leak.&whenJust Nothing $ \b -> print (not b)*whenJust (Just True) $ \b -> print (not b)FalseBreludeMonadic version of A..whenJustM (pure Nothing) $ \b -> print (not b)2whenJustM (pure $ Just True) $ \b -> print (not b)FalseCreludePerforms default < action if c( is given. Otherwise returns content of d pured to <.!whenNothing Nothing [True, False] [True,False]%whenNothing (Just True) [True, False][True]DreludePerforms default < action if c is given. Do nothing for d. Convenient for discarding d content.+whenNothing_ Nothing $ putTextLn "Nothing!"Nothing!/whenNothing_ (Just True) $ putTextLn "Nothing!"EreludeMonadic version of E.>whenNothingM (pure $ Just True) $ True <$ putTextLn "Is Just!"True>whenNothingM (pure Nothing) $ False <$ putTextLn "Is Nothing!" Is Nothing!FalseFreludeMonadic version of F.7whenNothingM_ (pure $ Just True) $ putTextLn "Is Just!"6whenNothingM_ (pure Nothing) $ putTextLn "Is Nothing!" Is Nothing!GreludeThe monadic version of the ;< function.:{#evenInHalf :: Int -> IO (Maybe Int) evenInHalf n& | even n = pure $ Just $ n `div` 2 | otherwise = pure Nothing:}mapMaybeM evenInHalf [1..10] [1,2,3,4,5]@ABCDEFG@ABCDEFG@0\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xkά Hrelude$Shorter and more readable alias for flip runReaderT.usingReaderT 42 $ asks (+5)47Irelude$Shorter and more readable alias for flip runReader.usingReader 42 $ asks (+5)47Jrelude$Shorter and more readable alias for flip runStateT.$usingStateT 0 $ put 42 >> pure False (False,42)Krelude$Shorter and more readable alias for  flip runState.Lrelude Alias for flip evalStateTE. It's not shorter but sometimes more readable. Done by analogy with using* functions family.Mrelude Alias for flip evalStateE. It's not shorter but sometimes more readable. Done by analogy with using* functions family.Nrelude Alias for flip execStateTE. It's not shorter but sometimes more readable. Done by analogy with using* functions family.Orelude Alias for flip execStateE. It's not shorter but sometimes more readable. Done by analogy with using* functions family.PreludeLift a O to the % monadQreludeLift a Y to the  monad HIJKLMNOPQ IHMLONKJPQ \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/7MXkӽRrelude Extracts C value from O returning # if 9=.+maybeToMonoid (Just [1,2,3] :: Maybe [Int])[1,2,3]&maybeToMonoid (Nothing :: Maybe [Int])[]0B"C#$%     R3C#$%     B"R\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkSreludeLike 1> but runs in  O(n \log n)  time and requires 3.ordNub [3, 3, 3, 2, 2, -1, 1] [3,2,-1,1]TreludeLike 1> but runs in  O(n \log_{16} n)  time and requires (.hashNub [3, 3, 3, 2, 2, -1, 1] [3,2,-1,1]UreludeLike S runs in  O(n \log n)  but also sorts a list.sortNub [3, 3, 3, 2, 2, -1, 1] [-1,1,2,3]VreludeLike T runs in  O(n \log_{16} n) 7 but has better performance; it doesn't save the order."unstableNub [3, 3, 3, 2, 2, -1, 1] [1,2,3,-1]STUVTSUV \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy ,./HUVXk xrelude,For tracking usage of Text instead of StringWreludeW takes & and splits it into the list by lines..Actual type of this function is the following:  lines ::  -> [] Obut it was given a more complex type to provide friendlier compile time errors.lines ""[]lines "one line" ["one line"]lines "line 1\nline 2"["line 1","line 2"]lines ("string line" :: String)...,... 'lines' works with 'Text', not 'String'. Possible fixes:> 1. Make sure OverloadedStrings extension is enabled.. 2. Apply 'toText' to a single value.2 3. Apply 'map toText' to the list value.... lines True...... 'lines' works with 'Text' But given: 'Bool'...XreludeX takes list of + values and joins them with line separator..Actual type of this function is the following:  unlines :: [] ->  Obut it was given a more complex type to provide friendlier compile time errors. unlines []""unlines ["line 1"] "line 1\n"%unlines ["first line", "second line"]"first line\nsecond line\n"*unlines (["line 1", "line 2"] :: [String])....... 'unlines' works with 'Text', not 'String'. Possible fixes:> 1. Make sure OverloadedStrings extension is enabled.. 2. Apply 'toText' to a single value.2 3. Apply 'map toText' to the list value....unlines [True, False]...... 'unlines' works with 'Text' But given: 'Bool'...YreludeY takes & and splits it into the list by words..Actual type of this function is the following:  words ::  -> [] Obut it was given a more complex type to provide friendlier compile time errors.words ""[]words "one line"["one","line"]words " >_< "[">_<"] words ("string words" :: String)...,... 'words' works with 'Text', not 'String'. Possible fixes:> 1. Make sure OverloadedStrings extension is enabled.. 2. Apply 'toText' to a single value.2 3. Apply 'map toText' to the list value.... words True...... 'words' works with 'Text' But given: 'Bool'...ZreludeZ takes list of , values and joins them with space character..Actual type of this function is the following:  unwords :: [] ->  Obut it was given a more complex type to provide friendlier compile time errors. unwords []""unwords ["singleWord"] "singleWord"unwords ["word", "another"]"word another")unwords (["word", "another"] :: [String])....... 'unwords' works with 'Text', not 'String'. Possible fixes:> 1. Make sure OverloadedStrings extension is enabled.. 2. Apply 'toText' to a single value.2 3. Apply 'map toText' to the list value....unwords [True, False]...... 'unwords' works with 'Text' But given: 'Bool'...4;45 WXYZ;445WXYZ \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None./=?@ACHUVXkq\[relude'Type class for lazy-strict conversions.yrelude,Helper type family to produce error messages^relude+Type class for converting other strings to .`relude+Type class for converting other strings to z.brelude+Type class for converting other strings to .drelude9Type class for conversion to utf8 representation of text.ereludeEncode as utf8 string (usually ?@).$encodeUtf8 @Text @ByteString "?0B0:"*"\208\191\208\176\209\130\208\176\208\186"freludeDecode from utf8 string.GdecodeUtf8 @Text @ByteString "\208\191\208\176\209\130\208\176\208\186""\1087\1072\1090\1072\1082"SputTextLn $ decodeUtf8 @Text @ByteString "\208\191\208\176\209\130\208\176\208\186"?0B0:greludeLDecode as utf8 string but returning execption if byte sequence is malformed.CdecodeUtf8 @Text @ByteString "\208\208\176\209\130\208\176\208\186""\65533\1072\1090\1072\1082"IdecodeUtf8Strict @Text @ByteString "\208\208\176\209\130\208\176\208\186"\Left Cannot decode byte '\xd0': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 streamhreludeType synonym for A@.ireludeType synonym for BC.jreludePolymorhpic version of {.readEither @Text @Int "123" Right 123readEither @Text @Int "aa"Left "Prelude.read: no parse"kreludeGeneralized version of 1D . Unlike 1Dm this function is polymorphic in its result type. This makes it more convenient to work with data types like  or %. However, if you pass the result of kX to a function that expects polymorphic argument, this can break type inference, so use -XTypeApplications( to specify the textual type explicitly.show (42 :: Int)"42"show (42 :: Double)"42.0"print (show @Text True)"True"lrelude Alias for ] function.mrelude Alias for \ function.nreludeoreludepreludesrelude Converting  to |J might be a slow operation. Consider using lazy bytestring at first place.relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:+toString ("some string" :: ShortByteString)...?... Type 'ShortByteString' doesn't have instance of 'ToString'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:7 decodeUtf8 :: ShortByteString -> StringO decodeUtf8Strict :: ShortByteString -> Either UnicodeException String...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:'toString ("some string" :: LByteString)...;... Type 'LByteString' doesn't have instance of 'ToString'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:3 decodeUtf8 :: LByteString -> StringK decodeUtf8Strict :: LByteString -> Either UnicodeException String...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:&toString ("some string" :: ByteString)...:... Type 'ByteString' doesn't have instance of 'ToString'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:2 decodeUtf8 :: ByteString -> StringJ decodeUtf8Strict :: ByteString -> Either UnicodeException String...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:*toLText ("some string" :: ShortByteString)...>... Type 'ShortByteString' doesn't have instance of 'ToLText'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:6 decodeUtf8 :: ShortByteString -> LTextN decodeUtf8Strict :: ShortByteString -> Either UnicodeException LText...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:&toLText ("some string" :: LByteString)...:... Type 'LByteString' doesn't have instance of 'ToLText'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:2 decodeUtf8 :: LByteString -> LTextJ decodeUtf8Strict :: LByteString -> Either UnicodeException LText...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:%toLText ("some string" :: ByteString)...9... Type 'ByteString' doesn't have instance of 'ToLText'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:1 decodeUtf8 :: ByteString -> LTextI decodeUtf8Strict :: ByteString -> Either UnicodeException LText...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:)toText ("some string" :: ShortByteString)...=... Type 'ShortByteString' doesn't have instance of 'ToText'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:5 decodeUtf8 :: ShortByteString -> TextM decodeUtf8Strict :: ShortByteString -> Either UnicodeException Text...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:%toText ("some string" :: LByteString)...9... Type 'LByteString' doesn't have instance of 'ToText'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:1 decodeUtf8 :: LByteString -> TextI decodeUtf8Strict :: LByteString -> Either UnicodeException Text...relude&CAUTION2& This instance is for custom error display only.7You should always specify encoding of bytes explicitly.?In case it is used by mistake, the user will see the following:$toText ("some string" :: ByteString)...8... Type 'ByteString' doesn't have instance of 'ToText'.C Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:0 decodeUtf8 :: ByteString -> TextH decodeUtf8Strict :: ByteString -> Either UnicodeException Text...[]\^_`abcdfeghijklmihdfegbc`a^_[]\lmjkE\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/XktI)4;45 WXYZ[]\^_`abcdfeghijklm\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy/=>?XkreludeLifted version of }.putText "Hello, world!" Hello, world!reludeLifted version of ~.putTextLn "Hello, world!" Hello, world!reludeLifted version of .putLText "Hello, world!" Hello, world!reludeLifted version of .putLTextLn "Hello, world!" Hello, world!reludeLifted version of .%putBS ("Hello, world!" :: ByteString) Hello, world!reludeLifted version of .'putBSLn ("Hello, world!" :: ByteString) Hello, world!reludeLifted version of .'putLBS ("Hello, world!" :: LByteString) Hello, world!reludeLifted version of .)putLBSLn ("Hello, world!" :: LByteString) Hello, world!\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/XkreludeLifted version of .reludeLifted version of .reludeLifted version of .(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/Xk reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of .  \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy,-./27HSUVXk relude Similar to  but data type.relude Version of FG that leaves warning.increment l = map (+1) lincrement [2, 3, 4][3,4,5]Kincrement l = trace ("incrementing each value of: " ++ show l) (map (+1) l)increment [2, 3, 4]#incrementing each value of: [2,3,4][3,4,5]relude Version of FH that leaves warning.increment l = map (+1) lincrement [2, 3, 4][3,4,5]&increment l = traceShow l (map (+1) l)increment [2, 3, 4][2,3,4][3,4,5]relude Version of FI that leaves warning.'traceShowId (1+2+3, "hello" ++ "world")(6,"helloworld")(6,"helloworld")relude Version of FJ that leaves warning.:{ let action :: Maybe Int action = do x <- Just 3 traceM ("x: " ++ show x) y <- pure 12 traceM ("y: " ++ show y) pure (x*2 + y) in action:}x: 3y: 12Just 18reludeLike  , but uses 9D$ on the argument to convert it to a .:{ let action :: Maybe Int action = do x <- Just 3 traceShowM x y <- pure 12 traceShowM y pure (x*2 + y) in action:}312Just 18relude Version of FK that leaves warning.traceId "hello""hellohello"reludetThrow pure errors. Use this function only to when you are sure that this branch of code execution is not possible.  DO NOT USE & as a normal error handling mechanism. error "oops"*** Exception: oopsCallStack (from HasCallStack):4 error, called at src/Relude/Debug.hs:204:11 in ......&CAUTION & Unlike Prelude version,  takes 9CM as an argument. In case it used by mistake, the user will see the following:error ("oops" :: String)...2... 'error' expects 'Text' but was given 'String'. Possible fixes:< * Make sure OverloadedStrings extension is enabled; * Use 'error (toText msg)' instead of 'error msg'... error False...... 'error' works with 'Text' But given: Bool...relude, that leaves warning in code on every usage.  \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk reludeMaps left part of Y to O.leftToMaybe (Left True) Just TrueleftToMaybe (Right "aba")NothingreludeMaps right part of Y to O.rightToMaybe (Left True)NothingrightToMaybe (Right "aba") Just "aba"reludeMaps O to Y wrapping default value into f.maybeToRight True (Just "aba") Right "aba"maybeToRight True Nothing Left TruereludeMaps O to Y wrapping default value into g.maybeToLeft True (Just "aba") Left "aba"maybeToLeft True Nothing Right TruereludeApplies given action to Y content if f- is given and returns the result. In case of g$ the default value will be returned.6whenLeft "bar" (Left 42) (\a -> "success!" <$ print a)42 "success!"7whenLeft "bar" (Right 42) (\a -> "success!" <$ print a)"bar"reludeApplies given action to Y content if f is given.whenLeft_ (Right 42) putTextLn whenLeft_ (Left "foo") putTextLnfooreludeMonadic version of .>whenLeftM "bar" (pure $ Left 42) (\a -> "success!" <$ print a)42 "success!"?whenLeftM "bar" (pure $ Right 42) (\a -> "success!" <$ print a)"bar"reludeMonadic version of .&whenLeftM_ (pure $ Right 42) putTextLn(whenLeftM_ (pure $ Left "foo") putTextLnfooreludeApplies given action to Y content if g- is given and returns the result. In case of f$ the default value will be returned.:whenRight "bar" (Left "foo") (\a -> "success!" <$ print a)"bar"8whenRight "bar" (Right 42) (\a -> "success!" <$ print a)42 "success!"reludeApplies given action to Y content if g is given.whenRight_ (Left "foo") printwhenRight_ (Right 42) print42reludeMonadic version of .BwhenRightM "bar" (pure $ Left "foo") (\a -> "success!" <$ print a)"bar"@whenRightM "bar" (pure $ Right 42) (\a -> "success!" <$ print a)42 "success!"reludeMonadic version of .%whenRightM_ (pure $ Left "foo") print#whenRightM_ (pure $ Right 42) print426776\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xkѧrelude>For chaining monadic operations in forward applications using (&) Named version of .0Just [ 1 :: Int ] & chainedTo (viaNonEmpty head)Just 1&Nothing & chainedTo (viaNonEmpty head)Nothingv&0:OcdYfg6789:;<=     !"%$#@ABCDEFGHIJKLMNOPQ\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xkrelude.For safe work with lists using functinons for .viaNonEmpty head [1]Just 1viaNonEmpty head []NothingreludePerforms given action over ! list if given list is non empty.+whenNotNull [] $ \(b :| _) -> print (not b)5whenNotNull [False,True] $ \(b :| _) -> print (not b)TruereludeMonadic version of .\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe %/@AXgkreludeType that represents exceptions used in cases when a particular codepath is not meant to be ever executed, but happens to be executed anyway.reludeaPattern synonym to easy pattern matching on exceptions. So intead of writing something like this: isNonCriticalExc :: SomeException -> Bool isNonCriticalExc e | Just (_ :: NodeAttackedError) <- fromException e = True | Just DialogUnexpected{} <- fromException e = True | otherwise = False  you can use  pattern synonym: isNonCriticalExc :: SomeException -> Bool isNonCriticalExc = case Exc (_ :: NodeAttackedError) -> True -- matching all exceptions of type NodeAttackedError Exc DialogUnexpected{} -> True _ -> False +This pattern is bidirectional. You can use Exc e instead of  toException e.reludeHGenerate a pure value which, when forced, will throw the given exceptionrelude_Generate a pure value which, when forced, will synchronously throw the exception wrapped into  data type.  \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/XkreludeLifted alias for  with clearer name.list = [2, 1, 3] :: [Int] :sprint listlist = _() <$ evaluateWHNF list :sprint list list = _ : _reludeLike  but discards value.list = [2, 1, 3] :: [Int] :sprint listlist = _evaluateWHNF_ list :sprint list list = _ : _relude Alias for evaluateWHNF . force with clearer name.list = [2, 1, 3] :: [Int] :sprint listlist = _() <$ evaluateNF list :sprint listlist = [2,1,3]relude Alias for evaluateWHNF . rnf . Similar to ! -- but discards resulting value.list = [2, 1, 3] :: [Int] :sprint listlist = _evaluateNF_ list :sprint listlist = [2,1,3]  \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkJreludeMonadic version of .+whenM (pure False) $ putTextLn "No text :(",whenM (pure True) $ putTextLn "Yes text :)" Yes text :)whenM (Just True) (pure ())Just ()whenM (Just False) (pure ())Just ()whenM Nothing (pure ())NothingreludeMonadic version of .-unlessM (pure False) $ putTextLn "No text :(" No text :(-unlessM (pure True) $ putTextLn "Yes text :)"reludeMonadic version of  if-then-else.@ifM (pure True) (putTextLn "True text") (putTextLn "False text") True textreludeMonadic version of @. Occasionally useful. Here some complex but real-life example: findSomePath :: IO (Maybe FilePath) somePath :: MaybeT IO FilePath somePath = do path <- MaybeT findSomePath guardM $ liftIO $ doesDirectoryExist path return path reludecEither lifts a value into an alternative context or gives a minimal value depending on a predicate.guarded even 3 :: [Int][]guarded even 2 :: [Int][2],guarded (const True) "hello" :: Maybe String Just "hello"-guarded (const False) "world" :: Maybe StringNothingBYou can use this function to implement smart constructors simpler: newtypey HttpHost = HttpHost { unHttpHost :: Text } mkHttpHost :: Text -> Maybe HttpHost mkHttpHost host = HttpHost <$>  (not . Text.null) host relude-Monadic version of 'Data.Bool.(&&)' operator.-Just False &&^ error "Shouldn't be evaluated" Just Falserelude-Monadic version of 'Data.Bool.(||)' operator.,Just True ||^ error "Shouldn't be evaluated" Just TrueL\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkDae(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/Xkrelude?Transforms an integer number to a bounded integral. It returns c3 for integers outside the bound of the return type.integerToBounded @Int 42Just 42integerToBounded @Int8 1024NothingreludeyTranforms an integer number to a natural. Only non-negative integers are considered natural, everything else will return c.integerToNatural (-1)NothingintegerToNatural 0Just 0integerToNatural 10Just 10`-ZYXWVUTSRQPONMLKJ. zy/xwvuts2  56edcba`_^]\[7~}|{F`GbHIJKLMNQRTUVWXfghijklmnopqr`ijHIJKLTUVWXfgh-ZYXWVUTSRQPONMLKJ6edcba`_^]\[F`Gb2  M. zy/xwvuts57~}|{QRklmnopqrN \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None /=>?HVXkANrelude>Typeclass for data types that can be created from one element.one True :: [Bool][True]one 'a' :: Text"a"&one (3, "hello") :: HashMap Int StringfromList [(3,"hello")]Laws: single-size: " x . size (one x) "a 1(where sizeS is a specific function for each container that returns the size of this container)relude(Type of single element of the structure.reludeCreate a list, map, , etc from a single element.reludeCreate singleton .one 42 :: IntSet fromList [42]IntSet.size (one x) == 1reludeCreate singleton +.one 42 :: HashSet Int fromList [42]"length (one @(HashSet Int) x) == 1reludeCreate singleton .one 42 :: Set Int fromList [42]length (one @(Set Int) x) == 1reludeCreate singleton  from key-value pair.one (3, "foo") :: IntMap TextfromList [(3,"foo")]$length (one @(IntMap String) x) == 1reludeCreate singleton * from key-value pair."one (3, "foo") :: HashMap Int TextfromList [(3,"foo")])length (one @(HashMap Int String) x) == 1reludeCreate singleton  from key-value pair.one (3, "foo") :: Map Int TextfromList [(3,"foo")]%length (one @(Map Int String) x) == 1reludeCreate singleton .one 97 :: ShortByteString"a"#ShortByteString.length (one x) == 1reludeCreate singleton lazy |.one 97 :: LByteString"a"LByteString.length (one x) == 1reludeCreate singleton strict .one 97 :: ByteString"a"ByteString.length (one x) == 1reludeCreate singleton lazy z.one 'a' :: LText"a"LText.length (one x) == 1reludeCreate singleton strict .one 'a' :: Text"a"Text.length (one x) == 1reludeCreate singleton .one 42 :: Seq Int fromList [42]length (one @(Seq Int) x) == 1reludeAllows to create singleton + list. You might prefer function with name  instead of 9M or (:|[]).one 42 :: NonEmpty Int42 :| []#length (one @(NonEmpty Int) x) == 1reludeGAllows to create a singleton list. You might prefer function with name  instead of 9M or (:[]).one 42 :: [Int][42]length (one @[Int] x) == 1N\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/XkC !()*+!\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy/XkIreludeSafer version of OM, returns a Maybe. get element from list using index value starting from `0`.[] !!? 0Nothing["a", "b", "c"] !!? 3Nothing[1, 2, 3] !!? (-1)Nothing["a", "b", "c"] !!? 2Just "c"4"#$%&'()*+,-./0123<=>?9  \(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy/XkT relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of .relude Lifted to  version of ."\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None -./HUVXk~ relude3Type family that produces compile-time errors when  and  functions are used with  and +.relude Similar to 1 but takes a function with its arguments flipped."flipfoldl' (/) 5 [2,3] :: Rational15 % 2CThis function can be useful for constructing containers from lists.reludeAlternative version of asum.8asumMap (\x -> if x > 2 then Just x else Nothing) [1..4]Just 3reludePolymorphic version of  concatMapA function.+foldMapA @[Int] (Just . replicate 3) [1..3]Just [1,1,1,2,2,2,3,3,3]reludePolymorphic version of  concatMapM function.+foldMapM @[Int] (Just . replicate 3) [1..3]Just [1,1,1,2,2,2,3,3,3]reludeStricter version of . sum [1..10]55reludeStricter version of .product [1..10]3628800reludeLike  but doesn't work on  and + for performance reasons.elem 'x' ("abc" :: String)False!elem False (one True :: Set Bool) ...B... Do not use 'elem' and 'notElem' methods from 'Foldable' on Set Suggestions: Instead of< elem :: (Foldable t, Eq a) => a -> t a -> Bool use3 member :: Ord a => a -> Set a -> Bool... Instead of? notElem :: (Foldable t, Eq a) => a -> t a -> Bool use not . member...reludeLike  but doesn't work on  and + for performance reasons.notElem 'x' ("abc" :: String)True$notElem False (one True :: Set Bool) ...B... Do not use 'elem' and 'notElem' methods from 'Foldable' on Set Suggestions: Instead of< elem :: (Foldable t, Eq a) => a -> t a -> Bool use3 member :: Ord a => a -> Set a -> Bool... Instead of? notElem :: (Foldable t, Eq a) => a -> t a -> Bool use not . member...reludeMonadic version of .andM [Just True, Just False] Just FalseandM [Just True] Just True%andM [Just True, Just False, Nothing] Just FalseandM [Just True, Nothing]NothingZandM [putTextLn "1" >> pure True, putTextLn "2" >> pure False, putTextLn "3" >> pure True]12FalsereludeMonadic version of .orM [Just True, Just False] Just TrueorM [Just True, Nothing] Just TrueorM [Nothing, Just True]NothingreludeMonadic version of .,allM (readMaybe >=> pure . even) ["6", "10"] Just True-allM (readMaybe >=> pure . even) ["5", "aba"] Just False.allM (readMaybe >=> pure . even) ["aba", "10"]NothingreludeMonadic version of .,anyM (readMaybe >=> pure . even) ["5", "10"] Just True.anyM (readMaybe >=> pure . even) ["10", "aba"] Just True.anyM (readMaybe >=> pure . even) ["aba", "10"]Nothing  P(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/XkH=>#(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None /HVXk?reludeModifiable Map.reludeWRead-only map or set. Contains polymorphic functions which work for both sets and maps. reludeOperator version of   function.=let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]myHashMap !? 'b' Just "yyy"myHashMap !? 'd'Nothingrelude Inverse of   function.=let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]notMember 'b' myHashMapFalsenotMember 'c' myHashMapTruereludexReturn the value to which the specified key is mapped, or the default value if this map contains no mapping for the key.=let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]!lookupDefault "zzz" 'b' myHashMap"yyy"!lookupDefault "zzz" 'c' myHashMap"zzz"relude:Converts the structure to the list of the key-value pairs.7toPairs (HashMap.fromList [('a', "xxx"), ('b', "yyy")])[('a',"xxx"),('b',"yyy")]relude/Converts the structure to the list of the keys.4keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])"ab"relude1Converts the structure to the list of the values.5elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")]) ["xxx","yyy"]reludeDefault value to return.relude Key to searchreludeContainer to search           9 $(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/XkreludeLifted version of QR.reludeLifted version of 1S.reludeLifted version of .reludeLifted version of .T\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None/Xkv'0123456789:;9\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com> Trustworthy/Xk  !&*+ ,-ZYXWVUTSRQPONMLKJ. zy/xwvuts012  3456edcba`_^]\[7~}|{89:;<(')=>?@AB"C#$%DaeEF`GbHIJKLMNOcdPhijQRSTUVWXYfgZ[\]^_klmnopqrutsxwv{zy~}|     ! "#$%&'()*+,-./0123456789:;<=>@?BACDIHGFEfghijklmnopqr      !"%$#&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]\^_`abcdfeghijklm%E(c) 2014 Chris Allen, Edward Kmett (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe,./HUVX_k= relude,Helper type family to produce error messages relude  is Y with a f that is a B.#relude Transform a   into an Y.$validationToEither (Success "whoop") Right "whoop"#validationToEither (Failure "nahh") Left "nahh"$relude Transform an Y into a  ."eitherToValidation (Right "whoop")Success "whoop" eitherToValidation (Left "nahh")Failure "nahh"*reludeHThis instance implements the following behavior for the binary operator: Both !: combine values inside ! using ". At least is ": return the left " (the earliest "). is ! #.Examples2success1 = Success [42] :: Validation [Text] [Int]2success2 = Success [69] :: Validation [Text] [Int]7failure1 = Failure ["WRONG"] :: Validation [Text] [Int]7failure2 = Failure ["FAIL"] :: Validation [Text] [Int]success1 <|> success2 Success [42]failure1 <|> failure2Failure ["WRONG","FAIL"]failure2 <|> success2 Success [69]+relude5This instance if the most important instance for the   data type. It's responsible for the many implementations. And it allows to accumulate errors while performing validation or combining the results in the applicative style.Examples.success1 = Success 42 :: Validation [Text] Int.success2 = Success 69 :: Validation [Text] Int:successF = Success (* 2) :: Validation [Text] (Int -> Int)5failure1 = Failure ["WRONG"] :: Validation [Text] Int5failure2 = Failure ["FAIL"] :: Validation [Text] IntsuccessF <*> success1 Success 84successF <*> failure1Failure ["WRONG"](+) <$> success1 <*> success2 Success 111(+) <$> failure1 <*> failure2Failure ["WRONG","FAIL"]liftA2 (+) success1 failure1Failure ["WRONG"]&liftA3 (,,) failure1 success1 failure2Failure ["WRONG","FAIL"]lImplementations of all functions are lazy and they correctly work if some arguments are not fully evaluated.:{#isFailure :: Validation e a -> BoolisFailure (Failure _) = TrueisFailure (Success _) = False:}failure1 *> failure2Failure ["WRONG","FAIL"] isFailure $ failure1 *> failure2TrueAepicFail = error "Impossible validation" :: Validation [Text] Int isFailure $ failure1 *> epicFailTrue,relude# is " #.-relude*This instances covers the following cases: Both ": combine values inside " with ".Both !: combine values inside ! with ".One ", one ! : return !.Examples2success1 = Success [42] :: Validation [Text] [Int]2success2 = Success [69] :: Validation [Text] [Int]7failure1 = Failure ["WRONG"] :: Validation [Text] [Int]7failure2 = Failure ["FAIL"] :: Validation [Text] [Int]success1 <> success2Success [42,69]failure1 <> failure2Failure ["WRONG","FAIL"]success1 <> failure1Failure ["WRONG"]/relude&CAUTION2& This instance is for custom error display only.&It's not possible to implement lawful 0 instance for  .?In case it is used by mistake, the user will see the following:GSuccess 42 >>= \n -> if even n then Success n else Failure ["Not even"]...:... Type 'Validation' doesn't have lawful 'Monad' instanceG which means that you can't use 'Monad' methods with 'Validation'.... "!#$ "!#$&(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe-./HUVXk3relude*Check that a type is an element of a list::kind! Elem String '[]Elem String '[] :: Bool= 'False!:kind! Elem String '[Int, String]"Elem String '[Int, String] :: Bool= 'True:kind! Elem String '[Int, Bool] Elem String '[Int, Bool] :: Bool= 'False4relude0Returns second element of tuple type (with kind *!) or type-level tuple (with kind (k1, k2), marked by prefix quote).:kind! Maybe (Snd '(Int, Text))Maybe (Snd '(Int, Text)) :: * = Maybe Text:kind! Maybe (Snd (Int, Text))Maybe (Snd (Int, Text)) :: * = Maybe Text5relude/Returns first element of tuple type (with kind *!) or type-level tuple (with kind (k1, k2), marked by prefix quote).:kind! Maybe (Fst '(Int, Text))Maybe (Fst '(Int, Text)) :: * = Maybe Int:kind! Maybe (Fst (Int, Text))Maybe (Fst (Int, Text)) :: * = Maybe Int6reludeBuilds combined [G by applying Constraint constructor to all elements of type-level list.(:kind! AllHave Show '[Int, Text, Double]/AllHave Show '[Int, Text, Double] :: Constraint:= (Show Int, (Show Text, (Show Double, () :: Constraint)))which is equivalent to: 1(Show Int, Show Text, Show Double) :: Constraint 7reludeConcatenates type-level lists.>:kind! '[ 'Just 5, 'Nothing] ++ '[ 'Just 3, 'Nothing, 'Just 1]A'[ 'Just 5, 'Nothing] ++ '[ 'Just 3, 'Nothing, 'Just 1] :: [MaybeB Nat]3= '[ 'Just 5, 'Nothing, 'Just 3, 'Nothing, 'Just 1],:kind! '[] ++ '[ 'Just 3, 'Nothing, 'Just 1]4'[] ++ '[ 'Just 3, 'Nothing, 'Just 1] :: [Maybe Nat] = '[ 'Just 3, 'Nothing, 'Just 1]8relude'Gets a string representation of a type.NOTE: This must be used with TypeApplications language extension. typeName @()"()" typeName @Int"Int"typeName @String"[Char]"typeName @(Maybe Int) "Maybe Int"34567887635475'(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/PXk9relude1Creates a tuple by pairing something with itself. dup "foo" ("foo","foo")dup ()((),()):reludeSee 9.;reludeNApply a function, with the result in the fst slot, and the value in the other. A dual to <mapToFst (+1) 10(11,10)<reludeQApply a function, with the result in the second slot, and the value in the other. A dual to ;.mapToSnd (+1) 10(10,11)=relude.Maps a function over both elements of a tuple.&mapBoth ("Hello " <>) ("Alice", "Bob")("Hello Alice","Hello Bob")>reludeApply a function that returns a value inside of a functor, with the output in the first slot, the input in the second, and the entire tuple inside the functor. A dual to ?traverseToFst (Just . (+1)) 10 Just (11,10) traverseToFst (const Nothing) 10Nothing?reludeApply a function that returns a value inside of a functor, with the output in the second slot, the input in the first, and the entire tuple inside the functor. A dual to >.traverseToSnd (Just . (+1)) 10 Just (10,11) traverseToSnd (const Nothing) 10Nothing@reludeMaps a function that returns a value inside of an applicative functor over both elements of a tuple, with the entire tuple inside the applicative functor.4traverseBoth (Just . ("Hello " <>)) ("Alice", "Bob") Just ("Hello Alice","Hello Bob")-traverseBoth (const Nothing) ("Alice", "Bob")Nothing9:;<=>?@9:;<=>?@((c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk"4AreludeUnwraps value from newtype.%newtype Size = Size Int deriving Showun @Int (Size 5)5%un (Size 5) == length ['a', 'x', 'b']FalseBreludeWraps value to newtype. Behaves exactly as AI but has more meaningnful name in case you need to convert some value to newtype.,newtype Flag = Flag Bool deriving (Show, Eq)wrap False == Flag TrueFalseCrelude#Applies function to the content of newtype.. This function is not supposed to be used on newtype7s that are created with the help of smart constructors.$newtype Foo = Foo Bool deriving Showunder not (Foo True) Foo False&newtype Bar = Bar String deriving Show'under (filter (== 'a')) (Bar "abacaba") Bar "aaaa"DreludeLift binary function for newtypes to work over underlying newtype representation.#under2 @(Sum Int) (<>) (3 :: Int) 47under2 @All (<>) True FalseFalseErelude Version of D that works on newtypeAs parametrized by their representation. Provided for convenience.underF2 @Sum (<>) (3 :: Int) 47underF2 @Max (<>) 'p' 't''t'FreluderCoercible composition. This function allows to write more efficient implementations of functions compoitions over newtypes.ABCDEFABCDEF)8(c) 2013-2016 Edward Kmett (c) 2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/SXk.PGreludegThe monomorphic lenses which don't change the type of the container (or of the value inside). It has a 1 constraint, and since both  and F are functors, it can be used whenever a getter or a setter is needed.a- is the type of the value inside of structures# is the type of the whole structureHreludeCreates G from the getter and setter.Irelude/Gets a value out of a structure using a getter.Jrelude5Sets the given value to the structure using a setter.Krelude)Applies the given function to the target.LreludeThe operator form of I with the arguments flipped.MreludeThe operator form of J.NreludeThe operator form of K.GHIJKLMNGHIJKLMNL4M4N4*(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>None /HVXk4Orelude<Groups elements using results of the given function as keys.2groupBy even [1..6] :: HashMap Bool (NonEmpty Int)/fromList [(False,5 :| [3,1]),(True,6 :| [4,2])]Prelude Similar to O% but keeps only one element as value.,groupOneBy even [1 .. 6] :: HashMap Bool IntfromList [(False,1),(True,2)]OPOP+=(c) 2011-2015 Edward Kmett (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe ./HUVXkQC relude)For tracking usage of ordinary list with Q functions.Qrelude;The class of foldable data structures that cannot be empty.RreludeTMap each element of the non-empty structure to a semigroup, and combine the results. foldMap1 SG.Sum (1 :| [2, 3, 4])Sum {getSum = 10}$foldMap1 show (123 :| [456, 789, 0]) "1234567890"Srelude@Combine the elements of a non-empty structure using a semigroup.$fold1 (1 :| [2, 3, 4 :: SG.Sum Int])Sum {getSum = 10}&fold1 (4 :| [5, 10 :: SG.Product Int])Product {getProduct = 200}Trelude5Convert a non-empty data structre to a NonEmpty list.toNonEmpty (Identity 2)2 :| []Urelude0The first element of a non-empty data structure.head1 (1 :| [2, 3, 4])1Vrelude/The last element of a non-empty data structure.last1 (1 :| [2, 3, 4])4Wrelude2The largest element of a non-empty data structure.!maximum1 (32 :| [64, 8, 128, 16])128Xrelude4The smallest elemenet of a non-empty data structure.!minimum1 (32 :| [64, 8, 128, 16])8Yrelude7Strictly folds non-empty structure with given function f: 0foldl1' f [x0, x1, x2 ...] = f (f x0 x1) x2 ... &foldl1' (++) ([1,2] :| [[3,4], [5,6]]) [1,2,3,4,5,6]`relude&CAUTION2& This instance is for custom error display only.Q+ is not supposed to be used with the lists.?In case it is used by mistake, the user will see the following:head1 [1, 2, 3] ...M... The methods of the 'Foldable1' type class work with non-empty containers.G However, one of the 'Foldable1' functions is applied to the List.... Possible fixes: * Replace []b with one of the: 'NonEmpty', 'Identity', '(c,)', 'Compose f g', 'Product f g', 'Sum f g'4 * Or use 'Foldable' class for your own risk.... QWXVSRTUY QWXVSRTUY,(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/XkYareludeWA left-associative fold that's tail-recursive but can still short-circuit. Returning a fF short-circuits and immediately returns the value inside. Returning a g3 continues the fold as usual with the value inside.HfoldlSC (\acc x -> if x == 0 then Left 0 else Right $! acc * x) 1 [1..6]720~foldlSC (\acc x -> if x == 0 then Left 0 else Right $! acc * x) 1 (0:error "Short-circuiting should keep this from happening")0aa-(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xkz>breludeReturns all values of some * + in ascending order.Edata TrafficLight = Red | Blue | Green deriving (Show, Enum, Bounded)universe :: [TrafficLight][Red,Blue,Green]universe :: [Bool] [False,True]crelude inverseMap f< creates a function that is the inverse of a given function f. It does so by constructing  internally for each value f a). The implementation makes sure that the 9 is constructed only once and then shared for every call.Memory usage note:. don't inverse functions that have types like H+ as their result. In this case the created  will have huge size.&The complexity of reversed mapping is \mathcal{O}(\log n).Performance note:E make sure to specialize monomorphic type of your functions that use c to avoid  reconstruction.One of the common c use-case is inverting the k or a k-like function.>data Color = Red | Green | Blue deriving (Show, Enum, Bounded)0parse = inverseMap show :: String -> Maybe Color parse "Red"Just Red parse "Black"NothingCorrectness note: c expects injective functionS as its argument, i.e. the function must map distinct arguments to distinct values./Typical usage of this function looks like this: dataM GhcVer = Ghc802 | Ghc822 | Ghc844 | Ghc865 | Ghc881 deriving (,, 3, 8, +, *) showGhcVer :: GhcVer ->  showGhcVer = \case Ghc802 -> "8.0.2" Ghc822 -> "8.2.2" Ghc844 -> "8.4.4" Ghc865 -> "8.6.5" Ghc881 -> "8.8.1" parseGhcVer ::  -> O GhcVer parseGhcVer = c showGhcVer dreludeLike , but doesn't fail on . Instead it returns . next FalseTrue next TrueFalse succ True3*** Exception: Prelude.Enum.Bool.succ: bad argumentereludeLike , but doesn't fail on . Instead it returns . prev FalseTrue prev TrueFalse pred False3*** Exception: Prelude.Enum.Bool.pred: bad argumentfreludeSee e.greludeReturns c if given H outside range.safeToEnum @Bool 0 Just FalsesafeToEnum @Bool 1 Just TruesafeToEnum @Bool 2NothingsafeToEnum @Bool (-1)Nothingbcdefgbcdefg.(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xk$hreludedThis function returns the name of its caller function, but it requires that the caller function has # constraint. Otherwise, it returns " unknown".,foo :: HasCallStack => String; foo = ownNamefoo"foo"(bar :: HasCallStack => String; bar = foobar"foo"ireludeThis function returns the name of its caller of the caller function, but it requires that the caller function and caller of the caller function have # constraint. Otherwise, it returns " unkown". It's useful for logging:Qlog :: HasCallStack => String -> IO (); log s = putStrLn $ callerName ++ ":" ++ sggreeting :: HasCallStack => IO (); greeting = log "Starting..." >> putStrLn "Hello!" >> log "Ending..."greetinggreeting:Starting...Hello!greeting:Ending...hihi/(c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Safe/Xkjrelude2Maps a function over both elements of a bifunctor.bimapBoth length ("a", "bb")(1,2),map (bimapBoth not) [Left True, Right False][Left False,Right True]krelude0Fmaps functions for nested bifunctor. Short for fmap (bimap f g).,bimapF not length $ Just (False, ['a', 'b']) Just (True,2)lrelude Short for  fmap . first.%firstF not $ Just (False, ['a', 'b'])Just (True,"ab")mrelude Short for  fmap . second.*secondF length $ Just (False, ['a', 'b'])Just (False,2)jklmjklm\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2019 KowainikMITKowainik <xrom.xkov@gmail.com>Unsafe/Xknrelude Similar to W but with flipped arguments. get element from list using index value starting from `0`.at 2 ["a", "b", "c"]"c"Bit is also usefull when used in a partially applied position like:8map (at 1) [["a","b","c"], ["a","b","c"], ["a","b","c"]] ["b","b","b"]nnUVWXYZU[\U[]U^_U^`UVaUVbUVcXYdUefUegUhiUjkUjlUjmUjnXopXoqUerUVsUVtUVuUVvUwxUyzUh{Uh|Uh}Uh~UUUUUVUVUVUVUVUVUVMUVUjUjXoUUhUhUVUVUeXoUUhUUhUUUwUyUVUUUUUUVUVXXXXXUUUUUUXUhUhXXUUUUUXXXUXUXXXU=UXUUXXXUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU U U U U UUUUUUUUUUUUUUUUUU U!U"U#U$%U&'U&(U)*U)+U,U-U.U/U0U1U2U3U4U5U6U7U8U9U:U;U<U=U>U?U@AU@BU@CU@CUDEUFGUFHUFHUIJUKLUKMUNOUNPUQRUQSUQTUQUUQVUKWUXYUZ[U\]U\^U_`U_aU_bU_cU_dUefUegUegUhUiUjUkUlUmUnUoUpUqUrUsU:UtUuUvUwUxUyUzU{U|U}U~U~U~U~U~U~U~U~U~UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUhUjUjUjUjUjUjUjUjUU[U[U[U[ U[OU[ U[ U[ U[ U[U[U[U[U[U[U[U[U[U[U[U[U[U[U;<U;U;U;U;U; U;!U;"U;#U$%U&0U&'U&(U)*U)+U),U)-U^.U^/U^0U12Ue3Ue4Ue5Ue6Ue7U89UV:UV;UV<UV=UV>UV2UV?UV@UVAUVBUVCUVDUVEUVFUVGUVHUVIUVJUVKUVLUVMUVNUVOUVPUVQUVRUVSUVTUVUUVUWUXU_`XoYXoZXo[Xo\Xo]Xo^Xo_Xo`XoaXobcdecdfcg@cdhijkilminoipqirstuvtuwtuxtuytuz{|}{|~{{{{{{{{{{{{{{{{{{{{{{C{{{{{  5678     D      !"#$%&'()*+,-./00GHIJ1K23456789:;<=>?@ABCDEFGHIJKLMMNOPQRSTUVWXYZ[\]^ _ ` a b c d e f g h i j k l m n o!p q r s t u v w x y z { |"}"~""""""""""##########################$R$S$$%%%%%%%%%%%%%%%%%%%&&&&&W&''''''''(((((())))))))**++++++++++++++++,------..////UXUXUXUUUUXU CUc@cccAcUI!UI"UI#!"#!"#c!c"c#cA!cA"cA#U3UZU1qU1rU1sU1tUuU1vU1wU1xU1yUQzUQ{UQ|"UUUUUIUI%+relude-0.6.0.0-inplaceRelude.List.Reexport Relude.BaseRelude.Container.ReexportRelude.Bool.ReexportRelude.FunctionRelude.NumericRelude.Monad.ReexportRelude.Functor.ReexportRelude.String.Reexport Relude.MonoidRelude.ApplicativeRelude.Foldable.ReexportRelude.Lifted.ConcurrentRelude.Lifted.IORefRelude.ExceptionRelude.Monad.Either Relude.UnsafeRelude.Functor.FmapRelude.DeepSeqRelude.Lifted.ExitRelude.Monad.MaybeRelude.Monad.Trans Relude.NubRelude.String.Conversion Relude.PrintRelude.Lifted.File Relude.File Relude.Debug Relude.MonadRelude.List.NonEmptyRelude.Bool.GuardRelude.Container.One Relude.ListRelude.Foldable.FoldRelude.Extra.MapRelude.Lifted.TerminalRelude.Extra.ValidationRelude.Extra.TypeRelude.Extra.TupleRelude.Extra.NewtypeRelude.Extra.LensRelude.Extra.GroupRelude.Extra.Foldable1Relude.Extra.FoldableRelude.Extra.EnumRelude.Extra.CallStackRelude.Extra.Bifunctor&PreludeidRelude.Functor System.ExitexitWith exitFailure exitSuccessdieReludefor_ Data.MaybemapMaybeNothingnubB ByteStringData.ByteString.LazyData.Text.LazyTextshow Relude.String Debug.Tracetrace traceShow traceShowIdtraceMtraceId Relude.BoolpureRelude.Container!!Relude.Foldable Data.TextgetLineprint Relude.LiftedbaseGHC.Base++ghc-primGHC.PrimseqGHC.Listfilterzip Data.Tuplefstsnd otherwisemap$coerceGHC.Num fromInteger-GHC.Real fromRationalGHC.EnumenumFrom enumFromThen enumFromToenumFromThenTo GHC.Classes==>=negate>>=>>fmapreturnControl.Monad.Failfail Data.String fromString fromIntegral realToFrac toInteger toRational Control.MonadguardGHC.ExtsIsListfromList fromListN<>memptymappendmconcatjoin<*>*>BoundedEnumEq GHC.FloatFloating FractionalIntegralMonadFunctorNumOrdGHC.ReadReadReal RealFloatRealFracGHC.ShowShowData.Typeable.InternalTypeable MonadFailIsString Applicative Data.FoldableFoldableData.Traversable Traversable GHC.GenericsGeneric GHC.TypeNatsKnownNatGHC.OverloadedLabelsIsLabel SemigroupMonoid GHC.TypesBoolCharDoubleFloatIntGHC.IntInt8Int16Int32Int64integer-wired-inGHC.Integer.TypeInteger GHC.NaturalNatural GHC.MaybeMaybeOrderingRatioRationalIOWordGHC.WordWord8Word16Word32Word64 Data.EitherEitherType ConstraintNatCmpNat CoercibleGHC.Stack.Types CallStackD#FalseF#JustTrueLeftRightLTEQGTGHC.IO.Handle.TypesHandleData.Functor.ContravariantcomparisonEquivalencedefaultEquivalencedefaultComparison>$$<>$<$<phantom>$ contramap Contravariant getPredicate Predicate getComparison ComparisongetEquivalence EquivalencegetOpOpData.Functor.Compose getComposeCompose Data.VoidvacuousabsurdVoidData.Semigroup mtimesDefaultcycle1 WrappedMonoid getOptionOptionsortWithData.BitraversablebifoldMapDefault bimapDefaultbifor bisequence bitraverse BitraversableData.BifoldablebifindbiallbianybiorbiandbielembilengthbinullbiListbiasum bisequence_bifor_ bitraverse_bifoldlMbifoldl'bifoldrMbifoldr'bifoldlbifoldr bifoldMapbifold BifoldableData.Bifunctorsecondfirstbimap BifunctorData.List.NonEmptynonEmptyGHC.ExecutionStackshowStackTrace getStackTraceControl.Monad.IO.ClassliftIOMonadIO fromLabelmfilter<$!>unless replicateM_ replicateM zipWithM_zipWithM mapAndUnzipMforever<=<>=>filterM mapAccumR mapAccumLforMsequencemapM sequenceAtraverseControl.Applicativeoptional getZipListZipList Control.Arrow&&&Data.Functor.Identity runIdentityIdentity System.IOwithFileGHC.IO.Handle.FDstderrstdin GHC.StackwithFrozenCallStack callStack GHC.Conc.Sync writeTVarreadTVarnewTVarSTMTVarstdout GHC.IORefIORefGHC.IOFilePath GHC.ExceptionprettyCallStack prettySrcLocGHC.Exception.Type SomeExceptiondisplayException fromException toException ExceptionData.Functor.ConstgetConstConstfindallanyorand concatMapconcatasum sequence_ sequenceA_forM_mapM_ traverse_foldlMlengthnulltoListfoldl'foldrfoldMap'foldMapfold Data.MonoidgetFirstFirstgetLastLastgetApApData.Semigroup.Internal stimesMonoidstimesIdempotentgetDualDualappEndoEndogetAllAllgetAnyAnygetSumSum getProductProductgetAltAlt someNatValnatValSomeNat Data.OldListunfoldrsortOnsortBysort permutations subsequencestailsinitsgroupgenericReplicategenericSplitAt genericDrop genericTake genericLength transpose intercalate intersperse isPrefixOf Text.Read readMaybereads fromRightfromLeftisRightisLeftpartitionEithersrightsleftseitherData.Ord comparingDown Data.ProxyProxyControl.Category>>><<< GHC.IO.IOMode ReadWriteMode AppendMode WriteModeReadModeIOModeatanhacoshasinhtanhcoshsinhatanacosasintancossinlogBase**sqrtexppiatan2isIEEEisNegativeZeroisDenormalized isInfiniteisNaN encodeFloat decodeFloat floatRange floatDigits floatRadix byteSwap64 byteSwap32 byteSwap16 Data.BitstoIntegralSizedxorlcmgcd^^^oddeven denominator numeratordivModquotRemmoddivremquotrecip/floorceilingroundtruncateproperFractionboundedEnumFromThenboundedEnumFrommaxBoundminBoundfromEnumtoEnumpredsuccGHC.Charchrunzip3unzipzipWithzip3reversebreaksplitAtdroptake dropWhile takeWhilecycle replicaterepeatiteratescanrscanlinitlasttailunconshead catMaybes listToMaybe maybeToList fromMaybefromJust isNothingisJustmaybe Data.Boolbool Data.Functiononfix Data.Functorvoid$><&><$>swapuncurrycurryGHC.MVarMVarsubtractsignumabs*+ GHC.Stack.CCScurrentCallStackasTypeOf$!flip.constmaxIntminIntordwhen=<<liftA3<**>stimessconcat<$<*liftA2manysome<|>empty Alternativemplusmzero MonadPlus:|NonEmptyString getCallStack HasCallStackstimesIdempotentMonoidcompare<<=>maxmin/=&&||notbytestring-0.10.9.0Data.ByteString.Short.Internal fromShortShortByteStringData.ByteString.InternaltoShortcontainers-0.6.2.1Data.IntMap.InternalIntMapData.IntSet.InternalIntSetData.Map.InternalMapData.Sequence.InternalSeqData.Set.InternalSetdeepseq-1.4.4.0Control.DeepSeqforce$!!deepseqrnfNFDatatransformers-0.5.6.2Control.Monad.Trans.Classlift MonadTransControl.Monad.Trans.Identity runIdentityT IdentityT mtl-2.2.2Control.Monad.State.Classgetsmodify'modifystateputget MonadStateControl.Monad.Reader.Classasksreaderlocalask MonadReaderControl.Monad.Trans.ExceptExceptT runExceptTControl.Monad.Trans.ReaderReaderT runReaderTReader runReader withReader withReaderT Control.Monad.Trans.State.StrictStateT runStateTStaterunState evalState execState withState evalStateT execStateT stm-2.5.0.0Control.Concurrent.STM.TVar modifyTVar' text-1.2.4.0Data.Text.Encoding decodeUtf8'decodeUtf8WithData.Text.InternalData.Text.Encoding.Error lenientDecode strictDecodeOnError OnDecodeErrorUnicodeExceptionControl.Monad.Trans.MaybeexceptToMaybeTmaybeToExceptT runMaybeTMaybeTpass appliedToQhashable-1.3.0.0-0adc683d0854628e4524d403338684b41b437ccad684ef76fe023f2db67763c9Data.Hashable.ClassHashable hashWithSalt^unordered-containers-0.2.10.0-997e4a72485757700a1dad676d87e92440e4a79c636d9b162c1a58c337e93890Data.HashMap.BaseHashMapData.HashSet.BaseHashSetidentity<<$>>flap??newIORef readIORef writeIORef modifyIORef modifyIORef'atomicModifyIORefatomicModifyIORef'atomicWriteIORef?:whenJust whenJustM whenNothing whenNothing_ whenNothingM whenNothingM_ mapMaybeM usingReaderT usingReader usingStateT usingStateevaluatingStateTevaluatingStateexecutingStateTexecutingState hoistMaybe hoistEither maybeToMonoidordNubhashNubsortNub unstableNublinesunlineswordsunwords LazyStricttoLazytoStrictToStringtoStringToLTexttoLTextToTexttoText ConvertUtf8 encodeUtf8 decodeUtf8decodeUtf8Strict LByteStringLText readEitherfromLazy fromStrict $fConvertUtf8TextShortByteString!$fConvertUtf8TextShortByteString0$fConvertUtf8[]ShortByteString$fConvertUtf8TextByteString$fConvertUtf8TextByteString0$fConvertUtf8[]ByteString$fConvertUtf8TextByteString1$fConvertUtf8TextByteString2$fConvertUtf8[]ByteString0 $fToTextText $fToTextText0 $fToText[] $fToLTextText$fToLTextText0 $fToLText[]$fToStringText$fToStringText0 $fToString[]$fToStringShortByteString$fToStringByteString$fToStringByteString0$fToLTextShortByteString$fToLTextByteString$fToLTextByteString0$fToTextShortByteString$fToTextByteString$fToTextByteString0$fLazyStrictTextText $fLazyStrictByteStringByteStringputText putTextLnputLText putLTextLnputBSputBSLnputLBSputLBSLnreadFile writeFile appendFile readFileText writeFileTextappendFileText readFileLTextwriteFileLTextappendFileLText readFileBS writeFileBS appendFileBS readFileLBS writeFileLBS appendFileLBS Undefined traceShowMerror undefined $fEqUndefined$fOrdUndefined$fShowUndefined$fReadUndefined$fEnumUndefined$fBoundedUndefined$fDataUndefined$fGenericUndefined leftToMaybe rightToMaybe maybeToRight maybeToLeftwhenLeft whenLeft_ whenLeftM whenLeftM_ whenRight whenRight_ whenRightM whenRightM_$fMonadFailEither chainedTo viaNonEmpty whenNotNull whenNotNullMBugExcbug$fExceptionBug $fShowBug evaluateWHNF evaluateWHNF_ evaluateNF evaluateNF_whenMunlessMifMguardMguarded&&^||^integerToBoundedintegerToNaturalOneOneItemone $fOneIntSet $fOneHashSet$fOneSet $fOneIntMap $fOneHashMap$fOneMap$fOneShortByteString$fOneByteString$fOneByteString0 $fOneText $fOneText0$fOneSeq $fOneNonEmpty$fOne[]!!? newEmptyMVarnewMVarputMVarreadMVarswapMVartakeMVar tryPutMVar tryReadMVar tryTakeMVar atomically newTVarIO readTVarIO flipfoldl'asumMapfoldMapAfoldMapMsumproductelemnotElemandMorMallManyM DynamicMapinsert insertWithdeletealter StaticMapKeyValsizelookupmember!? notMember lookupDefaulttoPairskeyselems$fStaticMapIntSet$fStaticMapHashSet$fStaticMapSet$fStaticMapIntMap$fStaticMapHashMap$fStaticMapMap$fDynamicMapIntMap$fDynamicMapHashMap$fDynamicMapMapputStrputStrLn ValidationFailureSuccessvalidationToEithereitherToValidation$fBitraversableValidation$fBifoldableValidation$fBifunctorValidation$fTraversableValidation$fFoldableValidation$fAlternativeValidation$fApplicativeValidation$fMonoidValidation$fSemigroupValidation$fFunctorValidation$fMonadValidation$fEqValidation$fOrdValidation$fShowValidationElemSndFstAllHavetypeNamedupdupemapToFstmapToSndmapBoth traverseToFst traverseToSnd traverseBothunwrapunderunder2underF2#.Lens'lensviewsetover^..~%~groupBy groupOneBy Foldable1foldMap1fold1 toNonEmptyhead1last1maximum1minimum1foldl1'$fFoldable1Sum$fFoldable1Product$fFoldable1Compose$fFoldable1(,)$fFoldable1Identity$fFoldable1NonEmpty $fFoldable1[]foldlSCuniverse inverseMapnextprevprec safeToEnumownName callerName bimapBothbimapFfirstFsecondFat Data.IORef IsNonEmptyIsText EncodingErrorData.Text.Internal.LazyData.ByteString.Lazy.Internal Data.Text.IOData.Text.Lazy.IOData.ByteStringData.ByteString.Char8Data.ByteString.Lazy.Char8GHC.Err impureThrowevaluateControl.Concurrent.MVar DisallowElemNoValidationMonadError IsListError