inter package:base

interact f takes the entire input from stdin and applies f to it. The resulting string is written to the stdout device. Note that this operation is lazy, which allows to produce output even before all input has been consumed. This operation may fail with the same errors as getContents and putStr.

Examples

>>> interact (\str -> str ++ str)
> hi :)
hi :)
> ^D
hi :)
>>> interact (const ":D")
:D
>>> interact (show . words)
> hello world!
> I hope you have a great day
> ^D
["hello","world!","I","hope","you","have","a","great","day"]
intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.

Laziness

intercalate has the following properties:
>>> take 5 (intercalate undefined ("Lorem" : undefined))
"Lorem"
>>> take 6 (intercalate ", " ("Lorem" : undefined))
"Lorem*** Exception: Prelude.undefined

Examples

>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"
>>> intercalate [0, 1] [[2, 3], [4, 5, 6], []]
[2,3,0,1,4,5,6,0,1]
>>> intercalate [1, 2, 3] [[], []]
[1,2,3]
The intersect function takes the list intersection of two lists. It is a special case of intersectBy, which allows the programmer to supply their own equality test.
Examples
>>> [1,2,3,4] `intersect` [2,4,6,8]
[2,4]
If equal elements are present in both lists, an element from the first list will be used, and all duplicates from the second list quashed:
>>> import Data.Semigroup

>>> intersect [Arg () "dog"] [Arg () "cow", Arg () "cat"]
[Arg () "dog"]
However if the first list contains duplicates, so will the result.
>>> "coot" `intersect` "heron"
"oo"

>>> "heron" `intersect` "coot"
"o"
If the second list is infinite, intersect either hangs or returns its first argument in full. Otherwise if the first list is infinite, intersect might be productive:
>>> intersect [100..] [0..]
[100,101,102,103...

>>> intersect [0] [1..]
* Hangs forever *

>>> intersect [1..] [0]
* Hangs forever *

>>> intersect (cycle [1..3]) [2]
[2,2,2,2...
The intersectBy function is the non-overloaded version of intersect. It is productive for infinite arguments only if the first one is a subset of the second.
The intersperse function takes an element and a list and `intersperses' that element between the elements of the list.

Laziness

intersperse has the following properties
>>> take 1 (intersperse undefined ('a' : undefined))
"a"
>>> take 2 (intersperse ',' ('a' : undefined))
"a*** Exception: Prelude.undefined

Examples

>>> intersperse ',' "abcde"
"a,b,c,d,e"
>>> intersperse 1 [3, 4, 5]
[3,1,4,1,5]
Allow asynchronous exceptions to be raised even inside mask, making the operation interruptible (see the discussion of "Interruptible operations" in Exception). When called outside mask, or inside uninterruptibleMask, this function has no effect.
Insert an m between each pair of t m.
>>> intercalate1 ", " $ "hello" :| ["how", "are", "you"]
"hello, how, are, you"
>>> intercalate1 ", " $ "hello" :| []
"hello"
>>> intercalate1 mempty $ "I" :| ["Am", "Fine", "You?"]
"IAmFineYou?"
'intersperse x xs' alternates elements of the list with copies of x.
intersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3]
Interrupts the current wait of the I/O manager if it is currently blocked. This instructs it to re-read how much it should wait and to process any pending events.
i
POSIX support layer for the standard libraries. The API of this module is unstable and not meant to be consumed by the general public. If you absolutely must depend on it, make sure to use a tight upper bound, e.g., base < 4.X rather than base < 5, because the interface can change rapidly without much warning. This module is built on *every* platform, including Win32. Non-POSIX compliant in order to support the following features: * S_ISSOCK (no sockets in POSIX)
Deprecated: This module will be removed from base in the next version (v4.22)
This module defines the basic operations on I/O "handles". All of the operations defined here are independent of the underlying device. The API of this module is unstable and not meant to be consumed by the general public. If you absolutely must depend on it, make sure to use a tight upper bound, e.g., base < 4.X rather than base < 5, because the interface can change rapidly without much warning.
Deprecated: This module will be removed from base in the next version (v4.22)
Deprecated: This module will be removed from base in the next version (v4.22)
the state during mask: asynchronous exceptions are masked, but blocking operations may still be interrupted
the state during uninterruptibleMask: asynchronous exceptions are masked, and blocking operations may not be interrupted
This exception is raised by default in the main thread of the program when the user requests to terminate the program via the usual mechanism(s) (e.g. Control-C in the console).
When invoked inside mask, this function allows a masked asynchronous exception to be raised, if one exists. It is equivalent to performing an interruptible operation (see #interruptible), but does not involve any actual blocking. When called outside mask, or inside uninterruptibleMask, this function has no effect.
Like mask, but the masked computation is not interruptible (see Control.Exception#interruptible). THIS SHOULD BE USED WITH GREAT CARE, because if a thread executing in uninterruptibleMask blocks for any reason, then the thread (and possibly the program, if this is the main thread) will be unresponsive and unkillable. This function should only be necessary if you need to mask exceptions around an interruptible operation, and you can guarantee that the interruptible operation will only block for a short period of time.
Like uninterruptibleMask, but does not pass a restore action to the argument.