module Ivory.Stdlib.Operators where
import Ivory.Language
(~>*) :: (IvoryVar a, IvoryStruct sym, IvoryRef ref,
IvoryExpr (ref s (Stored a)),
IvoryExpr (ref s (Struct sym))) =>
ref s (Struct sym) -> Label sym (Stored a) -> Ivory eff a
struct ~>* label = deref $ struct~>label
infixl 8 ~>*
(%=) :: IvoryStore a =>
Ref s (Stored a) -> (a -> a) -> Ivory eff ()
ref %= f = do
val <- deref ref
store ref (f val)
(%=!) :: IvoryStore a =>
Ref s (Stored a) -> (a -> Ivory eff a) -> Ivory eff ()
ref %=! mf = do
val <- deref ref
val' <- mf val
store ref val'
(+=) :: (Num a, IvoryStore a) =>
Ref s (Stored a) -> a -> Ivory eff ()
ref += x = ref %= (+ x)