Scanf.Scanning(3)
π NAME π
okay so this is Scanf.Scanning(3) from the OCaml library manual β and the NAME section is literally just βno descriptionβ π iconic minimalism, honestly. The way that this page is all about formatted input channels and scanning buffers but the NAME gave us nothing? not me side-eyeing the docs. Anyway, bestie, the Documentation section is where the actual main character energy lives, so let's go. π«Ά
π¦ Module π¦
Scanf.Scanning β that's the module, periodt. π
π Documentation π
Module Scanning : sig end
type in_channelβ the notion of input channel for theScanfmodule: those channels provide all the machinery necessary to read from any source of characters, including ain_channelvalue. AScanf.Scanning.in_channelvalue is also called a formatted input channel or equivalently a scanning buffer. The typeScanf.Scanning.scanbufbelow is an alias forScanning.in_channel.
β οΈ note: a Scanning.in_channel is not concurrency-safe β concurrent use may produce arbitrary values or exceptions. π it's giving chaos, fr fr.
Since 3.12. β¨
type scanbuf = in_channelβ the type of scanning buffers. A scanning buffer is the source from which a formatted input function gets characters. The scanning buffer holds the current state of the scan, plus a function to get the next char from the input, and a token buffer to store the string matched so far.
note: a scanning action may often require to examine one character in advance; when this 'lookahead' character does not belong to the token read, it is stored back in the scanning buffer and becomes the next character yet to be read. π¦ lowkey the buffer is holding onto that extra char for later.
val stdin : in_channelβ the standard input notion for theScanfmodule.Scanning.stdinis theScanf.Scanning.in_channelformatted input channel attached tostdin.
note: in the interactive system, when input is read fromstdin, the newline character that triggers evaluation is part of the input; thus, the scanning specifications must properly skip this additional newline character (for instance, simply add a'\n'as the last character of the format string). π yes bestie, that newline is part of the input, don't ignore it.
Since 3.12. π
type file_name = stringβ a convenient alias to designate a file name. Since 4.00. πval open_in : file_name -> in_channelβScanning.open_in fnamereturns aScanf.Scanning.in_channelformatted input channel for bufferized reading in text mode from filefname.
note:open_inreturns a formatted input channel that efficiently reads characters in large chunks; in contrast,from_channelbelow returns formatted input channels that must read one character at a time, leading to a much slower scanning rate. π vs π, iykyk.
Since 3.12. πΈ
val open_in_bin : file_name -> in_channelβScanning.open_in_bin fnamereturns aScanf.Scanning.in_channelformatted input channel for bufferized reading in binary mode from filefname. Since 3.12. π₯val close_in : in_channel -> unitβ closes thein_channelassociated with the givenScanf.Scanning.in_channelformatted input channel. Since 3.12. π periodt.val from_file : file_name -> in_channelβ an alias forScanf.Scanning.open_inabove. π«Άval from_file_bin : string -> in_channelβ an alias forScanf.Scanning.open_in_binabove. πval from_string : string -> in_channelβScanning.from_string sreturns aScanf.Scanning.in_channelformatted input channel which reads from the given string. Reading starts from the first character in the string. The end-of-input condition is set when the end of the string is reached. π ate.val from_function : (unit -> char) -> in_channelβScanning.from_function freturns aScanf.Scanning.in_channelformatted input channel with the given function as its reading method. When scanning needs one more character, the given function is called. When the function has no more character to provide, it must signal an end-of-input condition by raising the exceptionEnd_of_file. π₯ no cap.val from_channel : in_channel -> in_channelβScanning.from_channel icreturns aScanf.Scanning.in_channelformatted input channel which reads from the regularin_channelinput channelicargument. Reading starts at current reading position ofic. πval end_of_input : in_channel -> boolβScanning.end_of_input ictests the end-of-input condition of the givenScanf.Scanning.in_channelformatted input channel. β vibe check: are we at the end?val beginning_of_input : in_channel -> boolβScanning.beginning_of_input ictests the beginning of input condition of the givenScanf.Scanning.in_channelformatted input channel. πval name_of_input : in_channel -> stringβScanning.name_of_input icreturns the name of the character source for the givenScanf.Scanning.in_channelformatted input channel. Since 3.09. π
mwah π this page was brought to you by OCamldoc, dated 2026-06-22, for Scanf.Scanning(3) β go forth and scan your little heart out, bestie π«Άβ¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms