From 84d7e87817cd2c074653b34d028c8fa807febc7f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 5 Apr 2018 08:05:04 -0400 Subject: - Can now use resource/substructural types in pure computations. --- stdlib/source/lux/type/resource.lux | 38 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'stdlib/source') diff --git a/stdlib/source/lux/type/resource.lux b/stdlib/source/lux/type/resource.lux index 7de8fddf5..526dbecc9 100644 --- a/stdlib/source/lux/type/resource.lux +++ b/stdlib/source/lux/type/resource.lux @@ -4,7 +4,8 @@ ["ex" exception #+ exception:] [monad #+ Monad do] (monad [indexed #+ IxMonad])) - (data [maybe] + (data [identity #+ Identity] + [maybe] [product] [number] text/format @@ -64,8 +65,9 @@ [output procedure] (wrap [keys output]))))] - [IxMonad IO io.Monad run lift] - [IxMonad Promise promise.Monad run! lift!] + [IxMonad Identity identity.Monad run-pure lift-pure] + [IxMonad IO io.Monad run-sync lift-sync] + [IxMonad Promise promise.Monad run-async lift-async] ) (abstract: #export Ordered {} []) @@ -97,10 +99,12 @@ (function (_ keys) (:: wrap [[( []) keys] (@abstraction value)])))] - [ordered IO io.Monad Ordered ordered-key] - [ordered! Promise promise.Monad Ordered ordered-key] - [commutative IO io.Monad Commutative commutative-key] - [commutative! Promise promise.Monad Commutative commutative-key]) + [ordered-pure Identity identity.Monad Ordered ordered-key] + [ordered-sync IO io.Monad Ordered ordered-key] + [ordered-async Promise promise.Monad Ordered ordered-key] + [commutative-sync IO io.Monad Commutative commutative-key] + [commutative-pure Identity identity.Monad Commutative commutative-key] + [commutative-async Promise promise.Monad Commutative commutative-key]) (do-template [ ] [(def: #export ( resource) @@ -109,8 +113,9 @@ (function (_ [key keys]) (:: wrap [keys (@representation resource)])))] - [read IO io.Monad] - [read! Promise promise.Monad])) + [read-pure Identity identity.Monad] + [read-sync IO io.Monad] + [read-async Promise promise.Monad])) (exception: #export (Index-Cannot-Be-Repeated {index Nat}) (%n index)) @@ -165,8 +170,9 @@ (function ((~ g!_) [(~+ g!inputs) (~ g!context)]) (:: (~! ) (~' wrap) [[(~+ g!outputs) (~ g!context)] []]))))))))))] - [exchange IO io.Monad] - [exchange! Promise promise.Monad]) + [exchange-pure Identity identity.Monad] + [exchange-sync IO io.Monad] + [exchange-async Promise promise.Monad]) (def: amount (Syntax Nat) @@ -189,8 +195,10 @@ (function ((~ g!_) [ (~ g!context)]) (:: (~! ) (~' wrap) [[ (~ g!context)] []])))))))))] - [group IO io.Monad (~+ g!keys) [(~+ g!keys)]] - [group! Promise promise.Monad (~+ g!keys) [(~+ g!keys)]] - [un-group IO io.Monad [(~+ g!keys)] (~+ g!keys)] - [un-group! Promise promise.Monad [(~+ g!keys)] (~+ g!keys)] + [group-pure Identity identity.Monad (~+ g!keys) [(~+ g!keys)]] + [group-sync IO io.Monad (~+ g!keys) [(~+ g!keys)]] + [group-async Promise promise.Monad (~+ g!keys) [(~+ g!keys)]] + [un-group-pure Identity identity.Monad [(~+ g!keys)] (~+ g!keys)] + [un-group-sync IO io.Monad [(~+ g!keys)] (~+ g!keys)] + [un-group-async Promise promise.Monad [(~+ g!keys)] (~+ g!keys)] ) -- cgit v1.2.3