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