test.nim: Cleaner example of usage
This commit is contained in:
@ -2,8 +2,9 @@ import std/sugar
|
|||||||
|
|
||||||
# Declarations
|
# Declarations
|
||||||
|
|
||||||
type FileDesc* = enum STDIN, STDOUT, STDERR
|
type
|
||||||
type IO*[T] = proc(): T
|
FileDesc* = enum STDIN, STDOUT, STDERR
|
||||||
|
IO*[T] = proc(): T
|
||||||
|
|
||||||
func flatmap*[T, U](io: IO[T], fn: T -> IO[U]): IO[U]
|
func flatmap*[T, U](io: IO[T], fn: T -> IO[U]): IO[U]
|
||||||
func lift*(fn: proc(): void): IO[void]
|
func lift*(fn: proc(): void): IO[void]
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import enso
|
import enso
|
||||||
import std/strformat
|
import std/[strformat, sugar]
|
||||||
|
|
||||||
proc unsafe_void(str: string) =
|
proc unsafe_void(str: string) =
|
||||||
echo str
|
echo str
|
||||||
@ -14,8 +14,8 @@ func main() =
|
|||||||
run strput("Hello from Enso!")
|
run strput("Hello from Enso!")
|
||||||
|
|
||||||
let
|
let
|
||||||
out_void: IO[void] = lift do(): unsafe_void("void")
|
out_void: IO[void] = lift () => unsafe_void("void")
|
||||||
out_int: IO[int] = lift proc(): int = unsafe_int("int")
|
out_int: IO[int] = lift () => unsafe_int("int")
|
||||||
|
|
||||||
out_void()
|
out_void()
|
||||||
run strput(fmt"{out_int()}")
|
run strput(fmt"{out_int()}")
|
||||||
|
|||||||
Reference in New Issue
Block a user