!import "prelude" !Local !import "io" !Local !import "view" !Local -- View Contracts inside IO continuations -- Run with: -- -- tricu eval demos/viewContracts/io-continuation.tri --io -f decode -- -- Checked IO evaluation instruments continuation bodies once from source -- annotations. The IO runtime still executes ordinary interaction-tree actions; -- the returned continuations already contain the checked-exec guard boundaries. requireNonEmpty = (xs : lazyBool (_ : guardFail) (_ : guardOk xs) (emptyList? xs)) NonEmptyList elem = viewGuarded (viewList elem) requireNonEmpty acceptNames xs@(NonEmptyList String) =@String "accepted" useHandler handler@(Fn [(NonEmptyList String)] String) xs@(List String) =@String handler xs -- The IO action yields an empty list. The higher-order boundary requires a -- handler that accepts NonEmptyList String, so the continuation-internal pure -- call fails before returning the next IO value. main = io (bind (pure []) (xs : pure (useHandler acceptNames xs)))