Erlang Dependent Types Compiler Concurrency OTP Conclusion
Actors
data Actor : Type → Type → Type
proc : Actor l ()
Sam Elliott Erlang Meets Dependent Types
Slide 9
Slide 9 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Actors
data Actor : Type → Type → Type
proc : Actor l ()
recieve : Actor l l
Sam Elliott Erlang Meets Dependent Types
Slide 10
Slide 10 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Actors
data Actor : Type → Type → Type
proc : Actor l ()
recieve : Actor l l
spawn : (Actor l’ a) → Actor l (ActorID l’)
data ActorID : Type → Type
pid : ActorID l
Sam Elliott Erlang Meets Dependent Types
Slide 11
Slide 11 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Actors
data Actor : Type → Type → Type
proc : Actor l ()
recieve : Actor l l
spawn : (Actor l’ a) → Actor l (ActorID l’)
data ActorID : Type → Type
pid : ActorID l
send : ActorID l’ → l’ → Actor l ()
Sam Elliott Erlang Meets Dependent Types
Slide 12
Slide 12 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
RPC
data RPCLang : (r : Type)
→ (r → Type)
→ Type
Sam Elliott Erlang Meets Dependent Types
Slide 13
Slide 13 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
RPC
data RPCLang : (r : Type)
→ (r → Type)
→ Type
data LockReq = Lock | Unlock
data LockLockResp = Grant | Wait
total
LockResp : LockReq → Type
LockResp Lock = LockLockResp
LockResp Unlock = Unit
LockLang : RPCLang LockReq LockResp
Sam Elliott Erlang Meets Dependent Types
Slide 14
Slide 14 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
RPC II
data RPCRef : RPCLang rq rs → Type
rpc : {l : RPCLang rq rs}
→ RPCRef l
→ (m : rq)
→ EIO (rs m)
Sam Elliott Erlang Meets Dependent Types
Slide 15
Slide 15 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
RPC II
data RPCRef : RPCLang rq rs → Type
rpc : {l : RPCLang rq rs}
→ RPCRef l
→ (m : rq)
→ EIO (rs m)
pid : RPCRef LockLang
rpc pid Lock : LockLockResp
rpc pid Unlock : Unit
Sam Elliott Erlang Meets Dependent Types
Erlang Dependent Types Compiler Concurrency OTP Conclusion
RPC III
spawn : {l : RPCLang rq rs}
→ (r : rq → rs r)
→ EIO (RPCRef l)
total
lock : (m : LockReq) → LockResp m
lock Lock = Grant -- Oh Crap!
lock Unlock = ()
State? Side Effects?
Sam Elliott Erlang Meets Dependent Types
Slide 19
Slide 19 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
OTP
• “Open Telecoms Platform”
• Lots of great defaults
• Generic Behaviours!
• Supervisors!
Sam Elliott Erlang Meets Dependent Types
Slide 20
Slide 20 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Generic Behaviours
• gen server
• gen fsm
• gen event
Sam Elliott Erlang Meets Dependent Types
Slide 21
Slide 21 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
gen server
data GSL : (cl : Type)
→ (cl → Type)
→ Type
→ Type
data GSRef : GSL cl cr ct → Type
Sam Elliott Erlang Meets Dependent Types
Slide 22
Slide 22 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
gen server
data GSL : (cl : Type)
→ (cl → Type)
→ Type
→ Type
data GSRef : GSL cl cr ct → Type
call : {l : GSL cl cr ct}
→ GSRef l
→ (m : cl)
→ EIO (cr m)
cast : {l : GSL cl cr ct}
→ GSRef l
→ ct
→ EIO Unit
Sam Elliott Erlang Meets Dependent Types
Slide 23
Slide 23 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
gen server
data GS : (GSL cl cr ct)
→ Type
→ Type
→ Type
spawn : (GS l st i)
→ i
→ EIO (GSRef i)
Sam Elliott Erlang Meets Dependent Types
Slide 24
Slide 24 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Conclusion
• We can produce verified concurrent programs in Idris
• We can compile these programs to work with Erlang
• We can run verified programs in Erlang
Sam Elliott Erlang Meets Dependent Types
Slide 25
Slide 25 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Read More
Sam Elliott Erlang Meets Dependent Types
Slide 26
Slide 26 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Thanks To
Edwin Brady
Rob Stewart
Skyscanner & Mike Moran
Sam Elliott Erlang Meets Dependent Types
Slide 27
Slide 27 text
Erlang Dependent Types Compiler Concurrency OTP Conclusion
Any Questions?
Sam Elliott Erlang Meets Dependent Types