Simplee.IO
1.0.7
See the version list below for details.
dotnet add package Simplee.IO --version 1.0.7
NuGet\Install-Package Simplee.IO -Version 1.0.7
<PackageReference Include="Simplee.IO" Version="1.0.7" />
paket add Simplee.IO --version 1.0.7
#r "nuget: Simplee.IO, 1.0.7"
// Install Simplee.IO as a Cake Addin #addin nuget:?package=Simplee.IO&version=1.0.7 // Install Simplee.IO as a Cake Tool #tool nuget:?package=Simplee.IO&version=1.0.7
Koio |> Simple.IO
Library Simplee.IO v1.0.7 implements common IO functionality used by all other Simple projects. The namespace of the library is Simplee.IO.
Here is the main functionality exposed:
- io monad
- stdio operations
1. IO Monad
The library exposes a monad for IO. The main functions you can use are iorun which executes an IO flow, iobind which binds an IO monad to a given function. The library exposes a computation buildel, io, which can be used for imperative programing style.
let flow = io {
let! _ = putStrLn "Introduce line 1:"
let! cs1 = getLine
let! _ = putStrLn "Introduce line 2:"
let! cs2 = getLine
let! _ = putStrLn "You typed:"
return! putStrLn cs1
return! putStrLn cs2
}
flow |> iorun
2. stdio Operations
As you could see in the above example, the library exposes several convenience methods that allows you to interact with the stdio. All these functions are build on top of the IO monad.
For writing to the stdio, you can use: putChar, putStr, putStrLn. To get the input from stdio, you can use: getChar, getLine, getContent (this last function reads the stdio till the end).
let lines (s:string) = s.Split([|stdout.NewLine|], StringSplitOptions.None) |> Seq.ofArray
let length xs = Seq.length xs
let flow1 = io {
let! _ = putStrLn "Introduce line 1:"
let! cs1 = getLine
let! _ = putStrLn "Introduce line 2:"
let! cs2 = getLine
let! _ = putStrLn "You typed:"
return! putStrLn cs1
return! putStrLn cs2
}
let flow2 = io {
let! _ = putStrLn "Test contents:"
let! cs = getContents
return! putStr cs
}
let flow3 = io {
let! cs = getContents
return! cs |> lines |> length |> print
}
A. Installation
You can install the Simplee.IO nuget package by using one of the following commands:
PM> Install-Package Simplee.IO -Version 1.0.7
> dotnet add package Simplee.IO --version 1.0.7
> paket add Simplee.IO --version 1.0.7
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- FSharp.Core (>= 4.3.4)
- Simplee.Common (>= 1.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added the IO monad and stdin and stdout operations.