Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Erlang/OTP Meets Dependent Types

Sam Elliott
September 04, 2015

Erlang/OTP Meets Dependent Types

Talk given at Erlang Workshop 2015, September 2015.

Extended Abstract (for ICFP Student Research Competition): http://lenary.co.uk/publications/erlang_deptypes_src/

My Dissertation: http://lenary.co.uk/publications/dissertation/

Sam Elliott

September 04, 2015
Tweet

More Decks by Sam Elliott

Other Decks in Research

Transcript

  1. Introduction Compiler Concurrency OTP Conclusion Dependent Types • Types are

    Values • Values are Types • Programs and Proofs Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  2. Introduction Compiler Concurrency OTP Conclusion Actors data Actor : Type

    → Type → Type action : Actor interface term recieve : Actor i i spawn : (Actor i a) → IO (ActorID i) data ActorID : Type → Type pid : ActorID i send : ActorID i → i → IO () Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  3. Introduction Compiler Concurrency OTP Conclusion -type lock_req () :: lock

    | unlock. -type lock_lock_resp () :: grant | wait. -type lock_resp () :: lock_lock_resp () | ok. -type lock_st () :: locked | unlocked. -spec handle_call(lock_req (), term(), lock_st ()) → {ok , lock_resp (), lock_st ()} | error (). handle_call(lock , _, locked) → {ok , wait , locked}; handle_call(lock , _, unlocked) → {ok , grant , locked}; handle_call(unlock , _, locked) → {ok , ok , unlocked}; handle_call(unlock , _, unlocked) → {ok , ok , unlocked}. Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  4. Introduction Compiler Concurrency OTP Conclusion Request Response data ReqResI :

    (r : Type) → (r → Type) → Type data ReqResId : ReqResI r f → Type req : {i : ReqResI r f} → ReqResId i → (m : r) → IO (f m) spawn : {i : ReqResI r f} → ((m : r) → f m) → IO (ReqResId i) Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  5. Introduction Compiler Concurrency OTP Conclusion data LockReq = Lock |

    Unlock data LockLockResp = Grant | Wait total LockResp : LockReq → Type LockResp Lock = LockLockResp LockResp Unlock = Unit LockI : ReqResI LockReq LockResp total lock_srv : (r : LockReq) → LockResp r lock_srv Lock = Wait lock_srv Unlock = () spawn lock_srv : IO (ReqResId LockI) lock_pid : ReqResId LockI req lock_pid Lock : LockLockResp req lock_pid Unlock : Unit Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  6. Introduction Compiler Concurrency OTP Conclusion Behaviours • gen server •

    gen fsm • gen event Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types
  7. Introduction 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 Archibald Samuel Elliott, Edwin Brady Erlang/OTP Meets Dependent Types