test.nim: Cleaner example of usage

This commit is contained in:
buckwheat
2025-12-26 14:30:13 -08:00
parent fdba0b01d4
commit f3bdece63b
2 changed files with 6 additions and 5 deletions

View File

@ -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]

View File

@ -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()}")