(.module: [lux #* ["_" test (#+ Test)] [abstract [monad (#+ do)]] [control [io (#+ IO)] ["." try] [security ["!" capability]] [concurrency ["." promise (#+ Promise)]]] [math ["." random]]] {1 ["." /]}) (def: #export (spec console) (-> (IO (/.Console Promise)) Test) (<| (_.for [/.Console]) (do {! random.monad} [message (random.ascii/alpha 10)] (wrap (do promise.monad [console (promise.future console) ?read (!.use (\ console read) []) ?read_line (!.use (\ console read_line) []) ?write (!.use (\ console write) [message]) ?close/good (!.use (\ console close) []) ?close/bad (!.use (\ console close) [])] ($_ _.and' (_.cover' [/.Can_Read] (case [?read ?read_line] [(#try.Success _) (#try.Success _)] true _ false)) (_.cover' [/.Can_Write] (case ?write (#try.Success _) true _ false)) (_.cover' [/.Can_Close] (case [?close/good ?close/bad] [(#try.Success _) (#try.Failure _)] true _ false)) ))))))