// Effect aliases (ADR 0044): a row names a set once; the alias expands // to its members, so the type checker sees the same rows as ever. import std/io effect log { fn log :: msg: String -> () } effect ask { fn ask :: -> Int } effect state { fn get :: -> s fn put :: x: s -> () } effect alias app = log, ask // An alias expands in a signature's row. fn both :: { log "hi" let _ = ask () () } //~ TYPE both: fn() -> () / pub fn declared :: -> () / { both () } // Open rows keep their tail variable. pub fn open :: f: fn() -> a / -> a / { f () } //~ TYPE open: fn(fn() -> a / ) -> a / // A member that is itself an alias expands transitively; duplicates // collapse. effect alias deeper = app, log pub fn transitively :: -> () / { both () } // Applied members expand too. effect alias st = state pub fn counted :: -> Int / //~ WARN W0501 { let n = state.get () //~ ERROR E0109 state.put (n + 1) //~ ERROR E0109 n } // A dead member warns through the alias (W0501; coarser through an // alias: it reports the member dead in the alias even where it is live // in some other use). pub fn half_dead :: -> () / //~ WARN W0501 { log "yes" } // A bad member ends the alias's row in an error, once, without // cascading E0502 at every call (issue #144). effect alias unknown = nosucheffect //~ ERROR E0123 pub fn uses_unknown :: -> () / { io.println "fine" } effect alias selfy = selfy //~ ERROR E0122 refers to itself effect alias not_effects = Int //~ ERROR E0123 pub fn arity :: -> () / > //~ ERROR E0124 no type arguments //~^ WARN W0501 //~^^ WARN W0501 { () }