h&M4        !"# $ % & '( ) * +,-./012 345 6789:;< = > ? @AB C DE FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn o p q r s t u v w x y z { | } ~                                                                                                                                                                              !!"""""""#################$$$%%%%%%%%%%%%&&&&&&&&&&&&&&&&&&&&&&&&&&''''(())))))******++++++++,,--------------------..///0011119 (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2\reludeShorter alias for pure ().pass :: Maybe ()Just ()*Useful shortcut when need an empty action: printJust :: Maybe Int -> IO () printJust mInt = case mInt of Just i -> putStrLn $ "Number: " ++ show i Nothing -> pass reludeNamed version of the  operator, which is ( but flipped. It is helpful for chaining applicative operations in forward applications using 2.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-2023 KowainikMITKowainik StablePortable Trustworthy"2? -49:@AFQljkT\]^_`?F-4QljkT ^\]:@9A`_(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2( Dbf Dbf(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortable Trustworthy"2" !" !" (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2<>?<>?(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2reludeRenamed version of 34. identity 1010fmap identity [1,2,3][1,2,3]   (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2&2ponsrqvutyxw|{z}~&2ponsrqvutyxw|{z}~(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2relude Alias for  fmap . fmap%. Convenient to work with two nested 2s.negate <<$>> Just [1,2,3]Just [-1,-2,-3]reludeTakes a function in a 2* 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 8445(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2*2ponsrqvutyxw|{z}~(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2( relude1Creates a tuple by pairing something with itself. dup "foo" ("foo","foo")dup ()((),())reludeApply a function, with the result in the fst slot, and the value in the other. A dual to .toFst length [3, 1, 0, 2] (4,[3,1,0,2]) toFst (+5) 10(15,10)reludeApply a function, with the result in the snd slot, and the value in the other. A dual to .toSnd length [3, 1, 0, 2] ([3,1,0,2],4) toSnd (+5) 10(10,15)reludeLike 7, but also keep the original value in the snd position. A dual to .fmapToFst show [3, 10, 2][("3",3),("10",10),("2",2)]reludeLike 7, but also keep the original value in the fst position. A dual to .fmapToSnd show [3, 10, 2][(3,"3"),(10,"10"),(2,"2")]reludeApply a function, with the result in the fst slot, and the value in the other. A dual to mapToFst (+1) 10(11,10)reludeApply a function, with the result in the second slot, and the value in the other. A dual to .mapToSnd (+1) 10(10,11)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) 10NothingreludeApply 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) 10NothingreludeMaps 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")Nothing  (c) 2021-2023 KowainikMITKowainik StablePortableSafe"21reludeReturns all values of some + , in ascending order.universe :: [Bool] [False,True]universe @Ordering [LT,EQ,GT]data TrafficLight = Red | Blue | Green deriving (Show, Enum, Bounded)universe :: [TrafficLight][Red,Blue,Green]9data Singleton = Singleton deriving (Show, Enum, Bounded)universe @Singleton [Singleton]reludeLike , but returns [ list of some enumeration!universeNonEmpty :: NonEmpty BoolFalse :| [True]universeNonEmpty @Ordering LT :| [EQ,GT]data TrafficLight = Red | Blue | Green deriving (Show, Eq, Enum, Bounded))universeNonEmpty :: NonEmpty TrafficLightRed :| [Blue,Green]=data Singleton = Singleton deriving (Show, Eq, Enum, Bounded)universeNonEmpty @SingletonSingleton :| []relude 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 Int* as their input. In this case the created  will have huge size.&The complexity of reversed mapping is \mathcal{O}(\log n).Performance note: make sure to specialize monomorphic type of your functions that use  to avoid  reconstruction.One of the common  use-case is inverting the show or a show-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:  expects injective function as its argument, i.e. the function must map distinct arguments to distinct values./Typical usage of this function looks like this: data GhcVer = Ghc802 | Ghc822 | Ghc844 | Ghc865 | Ghc881 deriving (Eq, 4, Show, ,, +) showGhcVer :: GhcVer -> Text showGhcVer = \case Ghc802 -> "8.0.2" Ghc822 -> "8.2.2" Ghc844 -> "8.4.4" Ghc865 -> "8.6.5" Ghc881 -> "8.8.1" parseGhcVer :: Text -> P GhcVer parseGhcVer =  showGhcVer +, +, (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"24ireludeLifted version of 67.exitWith (ExitFailure 3)*** Exception: ExitFailure 3exitWith ExitSuccess*** Exception: ExitSuccessreludeLifted version of 68. exitFailure*** Exception: ExitFailure 1reludeLifted version of 69. exitSuccess*** Exception: ExitSuccessreludeLifted version of 6:.die "Goodbye!"Goodbye!*** Exception: ExitFailure 1(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2; reludeLifted version of .ref <- newIORef False:t refref :: IORef BoolreludeLifted version of .ref <- newIORef 42 readIORef ref42reludeLifted version of .ref <- newIORef 42writeIORef ref 43 readIORef ref43reludeLifted version of .ref <- newIORef 42modifyIORef ref (\a -> a + 6) readIORef ref48To avoid space-leaks, see  for stricter updatesFor atomic updates, see reludeLifted version of .ref <- newIORef 42modifyIORef' ref (\a -> a + 3) readIORef ref45For lazier updates, see For atomic updates, see reludeLifted version of .ref <- newIORef 42(atomicModifyIORef ref (\a -> (a, a + 3))45 readIORef ref42To avoid space-leaks, see  for stricter updates3If you are not interested in the return value, see reludeLifted version of .ref <- newIORef 42)atomicModifyIORef' ref (\a -> (a, a + 3))45 readIORef ref42For lazier updates, see 3If you are not interested in the return value, see relude Version of < that discards return value. Useful when you want to update , but not interested in the returning result.ref <- newIORef 42 atomicModifyIORef_ ref (`div` 2) readIORef ref21relude Version of < that discards return value. Useful when you want to update , but not interested in the returning result.ref <- newIORef 42!atomicModifyIORef'_ ref (`div` 2) readIORef ref21reludeLifted version of .ref <- newIORef 42atomicWriteIORef ref 45 readIORef ref45  (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortable Trustworthy"2>3reludeCreates an infinite list from a finite list by appending the list to itself infinite times (i.e. by cycling the list). Unlike cycle from  Data.List, this implementation doesn't throw error on empty lists, but returns an empty list instead.cycle [][]take 10 $ cycle [1,2,3][1,2,3,1,2,3,1,2,3,1]--(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2?'1;PdeZih'1;PdeZih(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2HMrelude Similar to  but with flipped arguments.readMaybe "True" ?: FalseTruereadMaybe "Tru" ?: FalseFalsereludeSpecialized version of ;< for P!. It's used for code readability.!Also helps to avoid space leaks:  http://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)FalsereludeMonadic version of ..whenJustM (pure Nothing) $ \b -> print (not b)2whenJustM (pure $ Just True) $ \b -> print (not b)FalsereludePerforms default = action if d( is given. Otherwise returns content of e pured to =.!whenNothing Nothing [True, False] [True,False]%whenNothing (Just True) [True, False][True]reludePerforms default = action if d is given. Do nothing for e. Convenient for discarding e content.+whenNothing_ Nothing $ putTextLn "Nothing!"Nothing!/whenNothing_ (Just True) $ putTextLn "Nothing!"reludeMonadic version of .>whenNothingM (pure $ Just True) $ True <$ putTextLn "Is Just!"True>whenNothingM (pure Nothing) $ False <$ putTextLn "Is Nothing!" Is Nothing!FalsereludeMonadic version of .7whenNothingM_ (pure $ Just True) $ putTextLn "Is Just!"6whenNothingM_ (pure Nothing) $ putTextLn "Is Nothing!" Is Nothing!reludeThe 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]0(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortable Trustworthy"2P relude$Shorter and more readable alias for flip runReaderT.usingReaderT 42 $ asks (+5)47relude$Shorter and more readable alias for flip runReader.usingReader 42 $ asks (+5)47reludeThis function helps with optimizing performance when working with the  transformer. If you have code like below, that is called in a loop step :: Instruction -> % Config IO Result step instruction = case instruction of Add -> do stuff ... Del -> do stuff ... you can improve performance of your Haskell applications by using  in the following way: step :: Instruction -> % Config IO Result step instruction =  $ case instruction of Add -> do stuff ... Del -> do stuff ... =For a detailed explanation, refer to the following blog post: https://www.joachim-breitner.de/blog/763-Faster_Winter_5__Eta-Expanding_ReaderT> pure False (False,42)relude$Shorter and more readable alias for  flip runState.relude Alias for flip evalStateT. It's not shorter but sometimes more readable. Done by analogy with using* functions family.relude Alias for flip evalState. It's not shorter but sometimes more readable. Done by analogy with using* functions family.relude Alias for flip execStateT. It's not shorter but sometimes more readable. Done by analogy with using* functions family.relude Alias for flip execState. It's not shorter but sometimes more readable. Done by analogy with using* functions family.reludeLift a P to the  monadreludeLift a Z to the  monad   (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2;TMrelude Extracts C value from P returning $ if ;?.+maybeToMonoid (Just [1,2,3] :: Maybe [Int])[1,2,3]&maybeToMonoid (Nothing :: Maybe [Int])[]reludeReturns the given value in case of the given predicate is satisfied (is f). Otherwise, it returns $.!memptyIfFalse True (Just "Hello") Just "Hello"$memptyIfFalse False "Doesn't matter"""reludeReturns the given value in case of the given predicate is unsatisfied (is b). Otherwise, it returns $. memptyIfTrue True (Just "Hello")Nothing memptyIfTrue False "Does matter" "Does matter"/B#C&$%2C&$%B#(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2ZreludeRemoves duplicate elements from a list, keeping only the first occurance of the element.Like 3@ but runs in  O(n \log n)  time and requires 4.ordNub [3, 3, 3, 2, 2, -1, 1] [3,2,-1,1]relude Similar to  but performs nub through the mapped list on the given function.3ordNubOn (`div` 10) [3, 3, 3, 13, 2, 22, -1, 1, 66][3,13,22,-1,66]reludeLike 3@ but runs in  O(n \log_{16} n)  time and requires .hashNub [3, 3, 3, 2, 2, -1, 1] [3,2,-1,1]reludeLike  runs in  O(n \log n)  but also sorts a list.sortNub [3, 3, 3, 2, 2, -1, 1] [-1,1,2,3]reludeLike  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]reludeRemoves duplicate elements from a list, keeping only the first occurance of the element.Like 3@ but runs in  O (n \min (n, int\_bits ))  time and requires 4.intNub [3, 3, 3, 2, 2, -1, 1] [3,2,-1,1]relude Similar to  but works on lists of any types by performing "nubbing" through Is.!intNubOn fromEnum "ababbbcdaffee""abcdfe" (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"/12frelude,For tracking usage of Text instead of Stringrelude takes & and splits it into the list by lines..Actual type of this function is the following:  lines ::  -> [] but 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'...relude takes list of + values and joins them with line separator..Actual type of this function is the following:  unlines :: [] ->  but 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'...relude takes & and splits it into the list by words..Actual type of this function is the following:  words ::  -> [] but 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'...relude takes list of , values and joins them with space character..Actual type of this function is the following:  unwords :: [] ->  but 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'...5<E<E5(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"12relude'Type class for lazy-strict conversions.relude,Helper type family to produce error messagesrelude+Type class for converting other strings to E.relude+Type class for converting other strings to .relude+Type class for converting other strings to .relude9Type class for conversion to utf8 representation of text.reludeEncode as utf8 string (usually AB).$encodeUtf8 @Text @ByteString ""*"\208\191\208\176\209\130\208\176\208\186"reludeDecode from utf8 string.decodeUtf8 @Text @ByteString "\208\191\208\176\209\130\208\176\208\186""\1087\1072\1090\1072\1082"putTextLn $ decodeUtf8 @Text @ByteString "\208\191\208\176\209\130\208\176\208\186"reludeDecode as utf8 string but returning execption if byte sequence is malformed.decodeUtf8 @Text @ByteString "\208\208\176\209\130\208\176\208\186""\65533\1072\1090\1072\1082"decodeUtf8Strict @Text @ByteString "\208\208\176\209\130\208\176\208\186"Left Cannot decode byte '\xd0': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 streamreludeType synonym for CB.reludeType synonym for DE.relude Version of  that returns  in case of the parse error.readEither @Int "123" Right 123readEither @Int "aa"Left "Prelude.read: no parse"reludeGeneralized version of 3F . Unlike 3F 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  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"relude Alias for  function.relude Alias for  function.reludereludereluderelude Converting E to  might be a slow operation. Consider using lazy bytestring at first place.reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:7 decodeUtf8 :: ShortByteString -> String decodeUtf8Strict :: ShortByteString -> Either UnicodeException String...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:3 decodeUtf8 :: LByteString -> String decodeUtf8Strict :: LByteString -> Either UnicodeException String...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:2 decodeUtf8 :: ByteString -> String decodeUtf8Strict :: ByteString -> Either UnicodeException String...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:6 decodeUtf8 :: ShortByteString -> LText decodeUtf8Strict :: ShortByteString -> Either UnicodeException LText...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:2 decodeUtf8 :: LByteString -> LText decodeUtf8Strict :: LByteString -> Either UnicodeException LText...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:1 decodeUtf8 :: ByteString -> LText decodeUtf8Strict :: ByteString -> Either UnicodeException LText...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:5 decodeUtf8 :: ShortByteString -> Text decodeUtf8Strict :: ShortByteString -> Either UnicodeException Text...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:1 decodeUtf8 :: LByteString -> Text decodeUtf8Strict :: LByteString -> Either UnicodeException Text...reludeMCAUTION2M 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'. Use 'decodeUtf8' or 'decodeUtf8Strict' to convert from UTF-8:0 decodeUtf8 :: ByteString -> Text decodeUtf8Strict :: ByteString -> Either UnicodeException Text...G(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2)5<E(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2reludeLifted 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-2023 KowainikMITKowainik StablePortableSafe"2reludeLifted version of .reludeLifted version of . Strict version of .reludeLifted version of .reludeLifted version of .(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2X 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-2023 KowainikMITKowainik StablePortable Trustworthy!"/0126;? relude Similar to  but data type.reludePrints the given E. message and returns the passed value of type a.increment l = map (+1) lincrement [2, 3, 4][3,4,5]increment 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]If you want to print a 9able value instead of E, use .+If you want to print the value itself, use .If you want to print by specifying a custom formatting function, use .relude Similar to # but prints a given value with the 9 instance instead of a E.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] If you want to print a specific E instead, use 4If you want to print and return the same value, use 7If you want to specify a custom printing function, use relude Similar to ? but prints the given value itself instead of a separate value.'traceShowId (1+2+3, "hello" ++ "world")(6,"helloworld")(6,"helloworld")2If you to specify a different value to print, use  or 4If you want to have more control over printing, use reludeSimilar , but uses a provided function to convert the argument to a value with the 9 constraint.traceShowWith fst (1, "ABC")1 (1,"ABC")In other words,  D  id.>This function is useful for debugging values that do not have 9 instance:fst $ traceShowWith fst (1, id)110If you don't need such flexibility, use simpler ,  or reludeTrace function to print values while working a pure monad (e.g. Maybe, State, etc.):{ 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 18&If you want to print a value with the 9 instance instead, use reludeLike  , but uses ;F$ on the argument to convert it to a E.:{ let action :: Maybe Int action = do x <- Just 3 traceShowM x y <- pure 12 traceShowM y pure (x*2 + y) in action:}312Just 18relude Similar to  but specialised for E.traceId "hello""hellohello"reludeThrow 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:289:11 in ......MCAUTION M Unlike Prelude version,  takes ;E 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-2023 KowainikMITKowainik StablePortableSafe"2 reludeMaps left part of Z to P.leftToMaybe (Left True) Just TrueleftToMaybe (Right "aba")NothingreludeMaps right part of Z to P.rightToMaybe (Left True)NothingrightToMaybe (Right "aba") Just "aba"reludeMaps P to Z wrapping default value into h.maybeToRight True (Just "aba") Right "aba"maybeToRight True Nothing Left TruereludeMaps P to Z wrapping default value into i.maybeToLeft True (Just "aba") Left "aba"maybeToLeft True Nothing Right TruereludeApplies given action to Z content if h- is given and returns the result. In case of i$ 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 Z content if h 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 Z content if i- is given and returns the result. In case of h$ 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 Z content if i is given.whenRight_ (Left "foo") printwhenRight_ (Right 42) print42reludeMonadic version of .whenRightM "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) print42reludeFor convenient work with ;.!(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2 relude>For chaining monadic operations in forward applications using (&) Named version of .0Just [ 1 :: Int ] & chainedTo (viaNonEmpty head)Just 1&Nothing & chainedTo (viaNonEmpty head)Nothingrelude%Repeat a monadic action indefinitely.$This is a more type safe version of ), which has a convenient but unsafe type.,Consider the following two examples. In the  getIntForever functions, it falsely expects Int as the result of the  function. But it would need to wait *forever* to get that, and this mistake won't be caught by the type system and compiler: getIntForever :: IO Int getIntForever = do i <- forever $ do ... pure i In contrast, using  instead of  in foo is a type error.'1;PdeZih(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"/12relude)For tracking usage of ordinary list with head-like functions.relude-For safe work with lists using functions 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 .reludeO(1)". Extracts the first element of a [ list..Actual type of this function is the following: head :: [ a -> a but 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' 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] but 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]' 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 but 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' 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] but 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]' 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... [g [g(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe "(2?+reludeType that represents exceptions used in cases when a particular codepath is not meant to be ever executed, but happens to be executed anyway.reludePattern synonym to easy pattern matching on exceptions. So instead 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.reludeGenerate a pure value which, when forced, will throw the given exceptionreludeGenerate 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-2023 KowainikMITKowainik StablePortableSafe"2reludeLifted alias for  with a clearer name.let list = [1..5] :: [Int] :sprint listlist = _() <$ evaluateWHNF list :sprint list list = 1 : _reludeLike  but discards value.let list = [1..5] :: [Int] :sprint listlist = _evaluateWHNF_ list :sprint list list = 1 : _relude Alias for evaluateWHNF . force with a clearer name.let list = [1..5] :: [Int] :sprint listlist = _() <$ evaluateNF list :sprint listlist = [1,2,3,4,5]relude Alias for evaluateWHNF . rnf . Similar to " but discards the resulting value.let list = [1..5] :: [Int] :sprint listlist = _evaluateNF_ list :sprint listlist = [1,2,3,4,5]  "(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2 reludeMonadic version of -. Conditionally executes the provided action.+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  . Reverse of 2. Conditionally don't execute the provided action.-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 textifM (pure False) (putTextLn "True text") (putTextLn "False text") False textreludeMonadic version of & that help to check that a condition (D) holds inside. Works with 1s that are also .guardM (Just True)Just ()guardM (Just False)NothingguardM NothingNothing(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 reludeEither lifts a value into an alternative context or gives a minimal value depending on a predicate. Works with s.guarded even 3 :: [Int][]guarded even 2 :: [Int][2],guarded (const True) "hello" :: Maybe String Just "hello"-guarded (const False) "world" :: Maybe StringNothingYou can use this function to implement smart constructors simpler: newtype HttpHost = HttpHost { unHttpHost :: Text } mkHttpHost :: Text -> Maybe HttpHost mkHttpHost host = HttpHost <$>  (not . Text.null) host reludeMonadic version of HI operator..It is lazy by the second argument (similar to HJ)), meaning that if the first argument is b, the function will return b( without evaluating the second argument.Just False &&^ Just True Just FalseJust True &&^ Just True Just TrueJust True &&^ NothingNothingJust False &&^ Nothing Just False-Just False &&^ error "Shouldn't be evaluated" Just FalsereludeMonadic version of HJ operator..It is lazy by the second argument (similar to HJ)), meaning that if the first argument is f, the function will return f( without evaluating the second argument.Just False ||^ Just True Just TrueJust False ||^ Just False Just FalseJust False ||^ NothingNothingJust True ||^ Nothing Just True,Just True ||^ error "Shouldn't be evaluated" Just TrueK(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2Dbf(c) 2018-2023 KowainikMITKowainik StablePortable Trustworthy"2relude?Transforms an integer number to a bounded integral. It returns d3 for integers outside the bound of the return type.integerToBounded @Int 42Just 42integerToBounded @Int8 1024Nothing3integerToBounded @Int (toInteger (minBound :: Int))Just (-9223372036854775808)9integerToBounded @Int $ (toInteger (minBound :: Int)) - 1Nothing3integerToBounded @Int (toInteger (maxBound :: Int))Just 92233720368547758079integerToBounded @Int $ (toInteger (maxBound :: Int)) + 1NothingIf you want to convert I or U# to a bounded type, take a look at  function instead.reludeTransforms an integer number to a natural. Only non-negative integers are considered natural, everything else will return d.integerToNatural (-1)NothingintegerToNatural 0Just 0integerToNatural 10Just 10./ 03 678GaHcIJKLMNORSUVWXYIJKLMUVWXY.7GaHc3 N/ 068RSO#(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe "2reludeTypeclass for data types that can be created from one element. E.g. lists, non-empty containers, maps.one True :: [Bool][True]one 'a' :: Text"a"&one (3, "hello") :: HashMap Int StringfromList [(3,"hello")]Laws: single-size: D x . size (one x) D 1(where size is a specific function for each container that returns the size of this container)relude*Type of a single element of the structure.reludeCreate a list, map, , etc from a single element.reludeCreate singleton .one 42 :: IntSet fromList [42] law> LM ( x) D 1 reludeCreate singleton .one 42 :: HashSet Int fromList [42] law> ;N ( @( a) x) D 1 reludeCreate singleton .one 42 :: Set Int fromList [42] law> ;N ( @( a) x) D 1 reludeCreate singleton  from key-value pair.one (3, "foo") :: IntMap TextfromList [(3,"foo")] law> ;N ( @( a) x) D 1 reludeCreate singleton  from key-value pair."one (3, "foo") :: HashMap Int TextfromList [(3,"foo")] law> ;N ( @( k v) (k, v)) D 1 reludeCreate singleton  from key-value pair.one (3, "foo") :: Map Int TextfromList [(3,"foo")] law> ;N ( @( k v) (k, v)) D 1 reludeCreate singleton .one 97 :: ShortByteString"a" law>  ( x) D 1 reludeCreate singleton lazy .one 97 :: LByteString"a" law>  ( x) D 1 reludeCreate singleton strict .one 97 :: ByteString"a" law>  ( x) D 1 reludeCreate singleton lazy .one 'a' :: LText"a" law> DN ( x) D 1 reludeCreate singleton strict .one 'a' :: Text"a" law> ON ( x) D 1 reludeCreate singleton .one 42 :: Seq Int fromList [42] law> ;N ( @( a) x) D 1 reludeAllows to create singleton [+ list. You might prefer function with name  instead of ;P or (:|[]).one 42 :: NonEmpty Int42 :| [] law> ;N ( @([ a) x) D 1 reludeAllows to create a singleton list. You might prefer function with name  instead of ;P or (:[]).one 42 :: [Int][42] law> ;N ( @[a] x) D 1 Q(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2ݹ !"$(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2reludeSafer version of R, 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"relude with its arguments flipped.:Get element from list using index value starting from `0`. maybeAt 0 []NothingmaybeAt 3 ["a", "b", "c"]NothingmaybeAt (-1) [1, 2, 3]NothingmaybeAt 2 ["a", "b", "c"]Just "c"reludePartitions a list based on the result of function which produces an Either value. List of all elements producing Left are extracted, in order, to the first element of the output tuple. Similarly, a list of all elements producing Right are extracted to the second element of output.:{- divideEvenOrShow :: Int -> Either Int String divideEvenOrShow n | even n = Left $ n `div` 2, | otherwise = Right $ "Odd: " <> show n :}'partitionWith divideEvenOrShow [1 .. 6]&([1,2,3],["Odd: 1","Odd: 3","Odd: 5"]):[g9 (c) 2020-2023 KowainikMITKowainik StablePortableSafe"2\reludeLifted version of .reludeLifted version of .reludeLifted version of .reludeLifted version of . m m(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2Erelude 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 .relude Lifted to  version of .relude Lifted to  version of .##%(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe "012 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 % 2This function can be useful for constructing containers from lists.reludeAlternative version of ;S# that takes a function to map over.8asumMap (\x -> if x > 2 then Just x else Nothing) [1..4]Just 3reludePolymorphic version of the ;T function.+foldMapA @[Int] (Just . replicate 3) [1..3]Just [1,1,1,2,2,2,3,3,3]reludePolymorphic version of the ;U 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) ...... 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) ...... 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]NothingandM [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  V(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2z>?&(c) 2018-2023 KowainikMITKowainik StablePortable Trustworthy "27reludeModifiable Map.reludeRead-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' myHashMapTruereludeReturn 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"]reludereludereludereludereludereludereludereludereludereludeDefault value to return.relude Key to searchreludeContainer to search9 '(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2reludeLifted version of OW.reludeLifted version of 3X.reludeLifted version of .reludeLifted version of .((c) 2020-2023 KowainikMITKowainik StablePortableSafe"2rreludeLifted version of YZ.reludeLifted version of Y[.\(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2Km;(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableSafe"2  !"'+, -./ 0123 456789:;<=*()>?@AB#C&$%DbfEFGaHcIJKLMNOPdeQljkRSTUVWXYZih[g\]^_`mponsrqvutyxw|{z}~)(c) 2018-2023 KowainikMITKowainik StablePortableSafe"012>relude*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= 'Falserelude0Returns 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 Textrelude/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 IntreludeBuilds combined ] 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 reludeConcatenates type-level lists.>:kind! '[ 'Just 5, 'Nothing] ++ '[ 'Just 3, 'Nothing, 'Just 1]'[ 'Just 5, 'Nothing] ++ '[ 'Just 3, 'Nothing, 'Just 1] :: [Maybe Natural]3= '[ 'Just 5, 'Nothing, 'Just 3, 'Nothing, 'Just 1],:kind! '[] ++ '[ 'Just 3, 'Nothing, 'Just 1]8'[] ++ '[ 'Just 3, 'Nothing, 'Just 1] :: [Maybe Natural] = '[ 'Just 3, 'Nothing, 'Just 1] # 85 "srcReludeExtra/Type.hs"relude'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"5*(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2reludeUnwraps value from newtype.%newtype Size = Size Int deriving Showun @Int (Size 5)5%un (Size 5) == length ['a', 'x', 'b']FalsereludeWraps value to newtype. Behaves exactly as  but has more meaningful name in case you need to convert some value to newtype.,newtype Flag = Flag Bool deriving (Show, Eq)wrap False == Flag TrueFalserelude#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"reludeLift binary function for newtypes to work over underlying newtype representation.#under2 @(Sum Int) (<>) (3 :: Int) 47under2 @All (<>) True FalseFalserelude Version of  that works on newtypes parametrized by their representation. Provided for convenience.underF2 @Sum (<>) (3 :: Int) 47underF2 @Max (<>) 'p' 't''t'reludeCoercible composition. This function allows to write more efficient implementations of function compositions over newtypes.+(c) 2012-2016 Edward Kmett (c) 2019-2023 KowainikMITKowainik StablePortableSafe"2reludeThe monomorphic lenses which don't change the type of the container (or of the value inside). It has a 2 constraint, and since both  and  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 structurereludeCreates  from the getter and setter.relude/Gets a value out of a structure using a getter.relude5Sets the given value to the structure using a setter.relude)Applies the given function to the target.reludeThe operator form of  with the arguments flipped.reludeThe operator form of .reludeThe operator form of .844,(c) 2018-2023 KowainikMITKowainik StablePortableSafe "2reludeStablePortableSafe "12$relude)For tracking usage of ordinary list with  functions.relude;The class of foldable data structures that cannot be empty.reludeMap 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"reludeCombine 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}reludeCombines the elements of a non-empty structure using a binary function f.foldr1 (+) 0 (1 :| [2, 3])6foldr1 (+) 1 $ Identity 34relude6Convert a non-empty data structure to a NonEmpty list.toNonEmpty (Identity 2)2 :| []relude0The first element of a non-empty data structure.head1 (1 :| [2, 3, 4])1relude/The last element of a non-empty data structure.last1 (1 :| [2, 3, 4])4relude2The largest element of a non-empty data structure.!maximum1 (32 :| [64, 8, 128, 16])128relude3The smallest element of a non-empty data structure.!minimum1 (32 :| [64, 8, 128, 16])8reludeThe largest element of a non-empty data structure with respect to the given comparison function.$maximumOn1 abs (0 :| [2, 1, -3, -2])-3reludeThe smallest element of a non-empty data structure with respect to the given comparison function.$minimumOn1 abs (0 :| [2, 1, -3, -2])0relude7Strictly 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]reludeGiven a  of / elements, computes the average if possible and returns the resulting element.average1 (42 :| [])42.0average1 (1 :| [2,3,4])2.5reludereludereludereludereludereludereludeMCAUTION2M This instance is for custom error display only.+ 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] ...... The methods of the 'Foldable1' type class work with non-empty containers. However, one of the 'Foldable1' functions is applied to the List.... Possible fixes: * Replace [] 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....  .(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2'reludeA left-associative fold that's tail-recursive but can still short-circuit. Returning a h short-circuits and immediately returns the value inside. Returning a i3 continues the fold as usual with the value inside.foldlSC (\acc x -> if x == 0 then Left 0 else Right $! acc * x) 1 [1..6]720foldlSC (\acc x -> if x == 0 then Left 0 else Right $! acc * x) 1 (0:error "Short-circuiting should keep this from happening")0reludeGiven a > of /8 elements, computes the average if possible and returns P element. average [42] Just 42.0average @Double [1, 2, 3, 4]Just 2.5average @Float [1.5, 2.5, 3 ,4] Just 2.75 average []Nothing/(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2*reludeLike , but doesn't fail on . Instead it returns . next FalseTrue next TrueFalse succ True3*** Exception: Prelude.Enum.Bool.succ: bad argumentreludeLike , but doesn't fail on . Instead it returns . prev TrueFalse prev FalseTrue pred False3*** Exception: Prelude.Enum.Bool.pred: bad argumentreludeReturns d if given I outside range.safeToEnum @Bool 0 Just FalsesafeToEnum @Bool 1 Just TruesafeToEnum @Bool 2NothingsafeToEnum @Bool (-1)Nothing0(c) 2018-2023 KowainikMITKowainik StablePortableSafe"2.9reludeThis 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"reludeThis 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 " unknown". It's useful for logging:log :: HasCallStack => String -> IO (); log s = putStrLn $ callerName ++ ":" ++ sgreeting :: HasCallStack => IO (); greeting = log "Starting..." >> putStrLn "Hello!" >> log "Ending..."greetinggreeting:Starting...Hello!greeting:Ending...1(c) 2018-2023 KowainikMITKowainik StablePortableSafe"20relude2Maps a function over both elements of a bifunctor.(bimapBoth length ([True], [False, True])(1,2),map (bimapBoth not) [Left True, Right False][Left False,Right True]relude0Fmaps functions for nested bifunctor. Short for fmap (bimap f g).,bimapF not length $ Just (False, ['a', 'b']) Just (True,2)relude Short for  fmap . first.%firstF not $ Just (False, ['a', 'b'])Just (True,"ab")relude Short for  fmap . second.*secondF length $ Just (False, ['a', 'b'])Just (False,2)](c) 2019-2023 KowainikMITKowainik StablePortable Safe-Inferred"21g(c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 KowainikMITKowainik StablePortableUnsafe"23relude Similar to  but with flipped arguments. get element from list using index value starting from `0`.at 2 ["a", "b", "c"]"c"it is also useful when used in a partially applied position like:8map (at 1) [["a","b","c"], ["a","b","c"], ["a","b","c"]] ["b","b","b"]^_`abc^de^df^gh^gi^_j^_k^_labm^no^np^qr^st^su^sv^swaxyaxz^n{^_|^_}^_~^_^^^^q^q^q^q^^^^^_^_^_^_^_^_^_P^_^s^sax^^q^q^_^_^nax^^q^^q^^^^^_^^^^^_^_a^_aaaa^^^^^a^q^qaa^^^^^^_aaa^^aaa^?^a^_^^aaa^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^N^^^^^^^^^^^<^^^^^^S^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^q^s^s^s^s^s^s^s^s^^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^d^dR^=^=^=>^=^=^=^=^=^=^H^^^2^^^^^g^g^g^^n^n^n^n^n^^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_4^_^_^_^_^_^_^_^^^^axIaxaxJaxaxaxaxaxaxaxBE  789:       F                   !!"""""""#################$$$%%%%%%%%%%%%&&&&&&&&&M&&&&&&&&&&&&&&&&&'W'X''(Z([)))))`)******++++++++,,--------------------..///001111^^^^^^^^ E^BC^^^^CCC^^NCNN^^^^^^^^^^^^^^^^%^^^^^^-%relude-1.2.0.0-JN67S4Yr7t2LNdEOp1vSFZRelude.List.Reexport Relude.BaseRelude.Container.ReexportRelude.Bool.ReexportRelude.FunctionRelude.Numeric Relude.EnumRelude.Monad.ReexportRelude.Functor.ReexportRelude.String.Reexport Relude.MonoidRelude.ApplicativeRelude.Foldable.ReexportRelude.List.NonEmptyRelude.Lifted.HandleRelude.Lifted.ConcurrentRelude.Lifted.IORefRelude.Exception Relude.UnsafeRelude.Monad.EitherRelude.Functor.FmapRelude.DeepSeqRelude.Extra.TupleRelude.Lifted.ExitRelude.Monad.MaybeRelude.Monad.Trans Relude.NubRelude.String.Conversion Relude.PrintRelude.Lifted.File Relude.File Relude.Debug Relude.MonadRelude.Bool.GuardRelude.Container.One Relude.ListRelude.Foldable.FoldRelude.Extra.MapRelude.Lifted.TerminalRelude.Lifted.EnvRelude.Extra.TypeRelude.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 Data.Bool&&|| Relude.Bool Data.IntSetsizelength Data.TextpureRelude.Container!!asum concatMapA concatMapMRelude.FoldablegetLineprintSystem.EnvironmentgetArgs lookupEnv Relude.Lifted Relude.ExtrabaseGHC.Base++ghc-primGHC.PrimseqGHC.Listfilterzip Data.Tuplefstsnd otherwisemap$coerceGHC.Num fromInteger-GHC.Real fromRationalGHC.EnumenumFrom enumFromThen enumFromToenumFromThenTo GHC.Classes==>=negate>>=>>fmapreturnControl.Monad.FailfailGHC.OverloadedLabels fromLabel 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.TypeNatsKnownNat SemigroupMonoid GHC.TypesBoolStringCharDoubleFloatIntGHC.IntInt8Int16Int32Int64 ghc-bignumGHC.Num.IntegerIntegerGHC.Num.NaturalNatural GHC.MaybeMaybeOrderingRatioRationalIOWordGHC.WordWord8Word16Word32Word64 Data.EitherEitherNonEmptyType Constraint CoercibleGHC.Stack.Types CallStackGHC.TypeNats.InternalCmpNatD#FalseF#JustTrue:|LeftRightLTEQGTGHC.IO.Handle.TypesHandleData.Functor.Contravariant getPredicate PredicategetOpOpgetEquivalence Equivalence contramap>$ Contravariant getComparison ComparisonphantomdefaultEquivalencedefaultComparisoncomparisonEquivalence>$<>$$<$<Data.Functor.Compose getComposeCompose Data.VoidVoidvacuousabsurdData.Semigroup WrappedMonoid mtimesDefaultcycle1sortWithData.Bitraversable bitraverse Bitraversable bisequence bimapDefaultbiforbifoldMapDefaultData.Bifoldablebifoldrbifoldl bifoldMapbifold Bifoldable bitraverse_ bisequence_biorbinullbilengthbifor_bifoldrMbifoldr'bifoldlMbifoldl'bifindbielembiasumbianybiandbiallbiListData.Bifunctorsecondfirstbimap BifunctorData.List.NonEmptynonEmptyGHC.ExecutionStackshowStackTrace getStackTraceControl.Monad.IO.ClassliftIOMonadIOIsLabel zipWithM_zipWithMunless replicateM_ replicateMmfilter mapAndUnzipMforeverfilterM>=><=<<$!>traverse sequenceAsequencemapM mapAccumR mapAccumLforMControl.Applicative getZipListZipListoptional Control.Arrow&&&Data.Functor.Identity runIdentityIdentityGHC.IO.StdHandleswithFilestdinstderr GHC.StackwithFrozenCallStack callStack GHC.Conc.SyncTVarSTM writeTVarthrowSTMreadTVarnewTVarcatchSTMstdout NoBuffering LineBufferingBlockBuffering BufferMode GHC.IORefIORefGHC.IOFilePath GHC.Exception prettySrcLocprettyCallStackGHC.Exception.Type SomeException toException fromExceptiondisplayException ExceptionData.Functor.ConstgetConstConsttoListnullfoldrfoldl'foldMap'foldMapfold traverse_ sequence_ sequenceA_ormapM_forM_foldlMfind concatMapconcatanyandall Data.OldListunfoldr transposetails subsequencessortOnsortBysort permutations isPrefixOf intersperse intercalateinitsgroup genericTakegenericSplitAtgenericReplicate genericLength genericDrop Data.MonoidgetLastLastgetFirstFirstgetApApData.Semigroup.InternalgetSumSum getProductProductappEndoEndogetDualDualgetAnyAnygetAltAltgetAllAll stimesMonoidstimesIdempotentSomeNatNat someNatValnatValData.OrdgetDownDown comparing Text.Readreads readMaybereadrightspartitionEithersleftsisRightisLeft fromRightfromLefteither Data.ProxyProxyControl.Category>>><<< GHC.IO.IOMode WriteMode ReadWriteModeReadMode AppendModeIOModeisNegativeZeroisNaN isInfiniteisIEEEisDenormalized floatRange floatRadix floatDigits encodeFloat decodeFloatatan2tanhtansqrtsinhsinpilogBaseexpcoshcosatanhatanasinhasinacoshacos** byteSwap64 byteSwap32 byteSwap16GHC.BitsxortoIntegralSizedtruncateroundproperFractionfloorceilingremquotRemquotmoddivModdivrecip/odd numeratorlcmgcdeven denominator^^^toEnumsuccpredfromEnumminBoundmaxBoundboundedEnumFromThenboundedEnumFromGHC.CharchrzipWithzip3unzip3unzipuncons takeWhiletaketailsplitAtspanscanr1scanrscanl1scanl'scanlreverse replicaterepeatlastiterateinithead dropWhiledropbreak maybeToListmaybe listToMaybe isNothingisJust fromMaybefromJust catMaybesbool Data.Functiononfix Data.Functorvoid<&><$>$>uncurryswapcurryGHC.MVarMVarsignumabs+*subtract GHC.Stack.CCScurrentCallStackstimessconcatmzeromplus MonadPlus<$liftA2<*somemanyempty<|> AlternativewhenordminIntmaxIntliftA3flipconstasTypeOf=<<<**>.$! HasCallStack getCallStackstimesIdempotentMonoidnot/=<<=>comparemaxminbytestring-0.11.3.1Data.ByteString.Short.Internal fromShortShortByteStringData.ByteString.InternaltoShortcontainers-0.6.5.1Data.IntMap.InternalIntMapData.IntSet.InternalIntSetData.Map.InternalMapData.Sequence.InternalSeqData.Set.InternalSetdeepseq-1.4.6.1Control.DeepSeqrnfNFDataforcedeepseq$!!'hashable-1.4.2.0-D6EOHOGayLdHLpjCLzeHpLData.Hashable.Class hashWithSaltHashabletransformers-0.5.6.2Control.Monad.Trans.Classlift MonadTransControl.Monad.Trans.Identity runIdentityT IdentityT mtl-2.2.2Control.Monad.State.Classstateputget MonadStatemodify'modifygetsControl.Monad.Reader.Classreaderlocalask MonadReaderasksControl.Monad.Trans.Except runExceptTExceptTControl.Monad.Trans.Reader runReader withReader withReaderTReaderReaderT runReaderT Control.Monad.Trans.State.Strict evalState evalStateT execState execStateTrunState withStateStateStateT runStateT stm-2.5.0.2Control.Concurrent.STM.TVar modifyTVar'Control.Concurrent.STM.TMVarTMVar tryTakeTMVar tryReadTMVar tryPutTMVar takeTMVar swapTMVar readTMVarputTMVarnewTMVar newEmptyTMVar mkWeakTMVar isEmptyTMVar text-1.2.5.0Data.Text.EncodingdecodeUtf8With decodeUtf8'Data.Text.InternalData.Text.Encoding.ErrorUnicodeExceptionOnError OnDecodeError strictDecode lenientDecodeControl.Monad.Trans.Maybe runMaybeTMaybeTmaybeToExceptTexceptToMaybeT3unordered-containers-0.2.19.1-IxllGDxiwx4nPRh3Oq5LRData.HashSet.InternalHashSetData.HashMap.InternalHashMappass appliedToidentity<<$>>flap??duptoFsttoSnd fmapToFst fmapToSndmapToFstmapToSnd traverseToFst traverseToSnd traverseBothuniverseuniverseNonEmpty inverseMapnewIORef readIORef writeIORef modifyIORef modifyIORef'atomicModifyIORefatomicModifyIORef'atomicModifyIORef_atomicModifyIORef'_atomicWriteIORefcycle?:whenJust whenJustM whenNothing whenNothing_ whenNothingM whenNothingM_ mapMaybeM usingReaderT usingReader etaReaderT usingStateT usingStateevaluatingStateTevaluatingStateexecutingStateTexecutingState hoistMaybe hoistEither maybeToMonoid memptyIfFalse memptyIfTrueordNubordNubOnhashNubsortNub unstableNubintNubintNubOnlinesunlineswordsunwords 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 readFile' writeFile appendFile readFileText writeFileTextappendFileText readFileLTextwriteFileLTextappendFileLText readFileBS writeFileBS appendFileBS readFileLBS writeFileLBS appendFileLBS Undefinedtrace traceShow traceShowId traceShowWithtraceM traceShowMtraceIderror undefined $fEqUndefined$fOrdUndefined$fShowUndefined$fReadUndefined$fEnumUndefined$fBoundedUndefined$fDataUndefined$fGenericUndefined leftToMaybe rightToMaybe maybeToRight maybeToLeftwhenLeft whenLeft_ whenLeftM whenLeftM_ whenRight whenRight_ whenRightM whenRightM_$fMonadFailEither chainedTo infinitely 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[]!!?maybeAt partitionWithhFlushhIsEOF hSetBuffering hGetBuffering newEmptyMVarnewMVarputMVarreadMVarswapMVartakeMVar tryPutMVar tryReadMVar tryTakeMVar atomically newTVarIO readTVarIO newTMVarIOnewEmptyTMVarIO flipfoldl'asumMapfoldMapAfoldMapMsumproductelemnotElemandMorMallManyM DynamicMapinsert insertWithdeletealter StaticMapKeyVallookupmember!? notMember lookupDefaulttoPairskeyselems$fStaticMapIntSet$fStaticMapHashSet$fStaticMapSet$fStaticMapIntMap$fStaticMapHashMap$fStaticMapMap$fDynamicMapIntMap$fDynamicMapHashMap$fDynamicMapMapputStrputStrLnElemSndFstAllHavetypeNameunwrapunderunder2underF2#.Lens'lensviewsetover^..~%~groupBy groupOneBy Foldable1foldMap1fold1foldr1 toNonEmptyhead1last1maximum1minimum1 maximumOn1 minimumOn1foldl1'average1$fFoldable1Sum$fFoldable1Product$fFoldable1Compose$fFoldable1(,)$fFoldable1Identity$fFoldable1NonEmpty $fFoldable1[]foldlSCaveragenextprev safeToEnumownName callerName bimapBothbimapFfirstFsecondFat Data.IORefIsText EncodingErrorData.Text.Internal.LazyData.ByteString.Lazy.Internal Data.Text.IOData.Text.Lazy.IOData.ByteStringData.ByteString.Char8Data.ByteString.Lazy.Char8 System.IOGHC.Err IsNonEmpty impureThrowevaluate GHC.IO.HandleControl.Concurrent.MVar DisallowElem IsListError