SlideShare a Scribd company logo
1 of 12
Download to read offline
SCaml compiler
DaiLambda, Inc.
Jun FURUSE/古瀬淳
, Université de Paris, 2019-11-22Tezos Smart Contracts
What is SCaml
Yet another compiler from OCaml to Michelson.
For Smart contracts
Strict Subset of OCaml
Small (< 3000 loc.).
and Serious
Strict Subset of OCaml
No fancy features for smart contracts
Many OCaml features are disabled:
No recursion
No polymoprhism
No modules
No objects
No mutability
No user defined types
Small
Built over OCaml’s compiler­libs.
Reusing OCaml’s parser and type-checker,
which are well tested for long time.
SCaml code only compiles OCaml’s typed AST to Michelson.
Less than 3000 lines of *.ml, written in 5 days.
and Serious
Serious compiler. Not a toy.
All the Michelson opcodes are supported, except
CREATE_CONTRACT.
Some optimizations in the pure ML level.
Babylon ready (i.e. entry points, closures)
Benefit of being Strict Subset
OCaml programmers can use SCaml without any surprise.
Newbies can learn SCaml via OCaml tutorial.
Many OCaml eco-system tools can be used for free:
Menhir, Tuareg, indender, reformatter
PPX, P4, ReasonML
etc.
Possibilities of being Strict Subset
Contracts can be compiled to native code with a
proper OCaml library:
Fast Monte Carlo simulations of contracts.
Contract, UI and server together in OCaml.
“Ocsigen” for Tezos:
Contracts: to Michelson by SCaml
UI: to JS by JSOO
Server: to native by OCaml
Compilation path
Parsing by OCaml parser
Typing by OCaml type checker
Unifying types for entry points and storage
Translation to an IL, pure monomorhpic core ML
Some inlining and partial evaluation
Compilation to Michelson
SCaml Features
Numeric types: int, nat, tz
Int (­12),   Nat 42,   Tz 1.23
with monomorphic operators: (+), (+^),(+$)
Options, Lists, Sets, Maps:
Some 1,   [ 1; 2; 3 ]
Set [ 1; 2; 3 ],  Map [ (1, "one"), (2, "two") ]
Blockchain related constants with strings:
Key_hash "tz1..."
Pairs, Sums:
int * int,  (int, int) sum
No user defined data types… yet
Aliases are OK: type 'a t = (int * ('a, nat) sum)
Future Work
Pattern match (almost done)
User defined types
Nothing more. We keep things small.
Vague Idea of Collaboration
SCaml + ReFX = SCaml + refinement type
Refinement specification as SCaml annotations.
Compiles down them to annotations in Michelson.
SCam Language
A scam never calls it a scam.
https://gitlab.com/dailambda/scaml

More Related Content

Similar to SCaml compiler

Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextEdward Willink
 
Open cl programming using python syntax
Open cl programming using python syntaxOpen cl programming using python syntax
Open cl programming using python syntaxcsandit
 
OpenCL programming using Python syntax
OpenCL programming using Python syntax OpenCL programming using Python syntax
OpenCL programming using Python syntax cscpconf
 
Cpp17 and Beyond
Cpp17 and BeyondCpp17 and Beyond
Cpp17 and BeyondComicSansMS
 
Porting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to RustPorting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to RustEvan Chan
 
Whats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ DevelopersWhats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ DevelopersRainer Stropek
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeDmitri Nesteruk
 
FPGA design with CλaSH
FPGA design with CλaSHFPGA design with CλaSH
FPGA design with CλaSHConrad Parker
 
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...AMD Developer Central
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practicesIwan van der Kleijn
 
Blockchain and Smart Contract Simulation
Blockchain and Smart Contract SimulationBlockchain and Smart Contract Simulation
Blockchain and Smart Contract SimulationJun Furuse
 
Optimizing Tcl Bytecode
Optimizing Tcl BytecodeOptimizing Tcl Bytecode
Optimizing Tcl BytecodeDonal Fellows
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS EngineChengHui Weng
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
Writing Efficient Code Feb 08
Writing Efficient Code Feb 08Writing Efficient Code Feb 08
Writing Efficient Code Feb 08Ganesh Samarthyam
 
Haskell Symposium 2010: An LLVM backend for GHC
Haskell Symposium 2010: An LLVM backend for GHCHaskell Symposium 2010: An LLVM backend for GHC
Haskell Symposium 2010: An LLVM backend for GHCdterei
 

Similar to SCaml compiler (20)

COM Introduction
COM IntroductionCOM Introduction
COM Introduction
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for Xtext
 
Open cl programming using python syntax
Open cl programming using python syntaxOpen cl programming using python syntax
Open cl programming using python syntax
 
OpenCL programming using Python syntax
OpenCL programming using Python syntax OpenCL programming using Python syntax
OpenCL programming using Python syntax
 
Cpp17 and Beyond
Cpp17 and BeyondCpp17 and Beyond
Cpp17 and Beyond
 
Porting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to RustPorting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to Rust
 
1.Philosophy of .NET
1.Philosophy of .NET1.Philosophy of .NET
1.Philosophy of .NET
 
Whats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ DevelopersWhats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ Developers
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
FPGA design with CλaSH
FPGA design with CλaSHFPGA design with CλaSH
FPGA design with CλaSH
 
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 
Blockchain and Smart Contract Simulation
Blockchain and Smart Contract SimulationBlockchain and Smart Contract Simulation
Blockchain and Smart Contract Simulation
 
Optimizing Tcl Bytecode
Optimizing Tcl BytecodeOptimizing Tcl Bytecode
Optimizing Tcl Bytecode
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
 
Circuit Simplifier
Circuit SimplifierCircuit Simplifier
Circuit Simplifier
 
Overview Of Msil
Overview Of MsilOverview Of Msil
Overview Of Msil
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
Writing Efficient Code Feb 08
Writing Efficient Code Feb 08Writing Efficient Code Feb 08
Writing Efficient Code Feb 08
 
Haskell Symposium 2010: An LLVM backend for GHC
Haskell Symposium 2010: An LLVM backend for GHCHaskell Symposium 2010: An LLVM backend for GHC
Haskell Symposium 2010: An LLVM backend for GHC
 

More from Jun Furuse

Tezos 008 Edo protocol
Tezos 008 Edo protocolTezos 008 Edo protocol
Tezos 008 Edo protocolJun Furuse
 
Plebeia, a new storage for Tezos blockchain state
Plebeia, a new storage for Tezos blockchain statePlebeia, a new storage for Tezos blockchain state
Plebeia, a new storage for Tezos blockchain stateJun Furuse
 
Tezso and on-chain governanace: towards "Kyoto amendment"
Tezso  and on-chain governanace: towards "Kyoto amendment"Tezso  and on-chain governanace: towards "Kyoto amendment"
Tezso and on-chain governanace: towards "Kyoto amendment"Jun Furuse
 
Comparison of Proof of Stakes
Comparison of Proof of StakesComparison of Proof of Stakes
Comparison of Proof of StakesJun Furuse
 
SCaml compiler
SCaml compilerSCaml compiler
SCaml compilerJun Furuse
 
Blockchain and formal verification (Japanese)
Blockchain and formal verification (Japanese)Blockchain and formal verification (Japanese)
Blockchain and formal verification (Japanese)Jun Furuse
 
Blockchain and Formal verification (English)
Blockchain and Formal verification (English)Blockchain and Formal verification (English)
Blockchain and Formal verification (English)Jun Furuse
 
Tezos Hands on 2019-06-15 Exercise (Japanese)
Tezos Hands on 2019-06-15 Exercise (Japanese)Tezos Hands on 2019-06-15 Exercise (Japanese)
Tezos Hands on 2019-06-15 Exercise (Japanese)Jun Furuse
 
Tezos Hands on 2019-06-15 (Japanese)
Tezos Hands on 2019-06-15 (Japanese)Tezos Hands on 2019-06-15 (Japanese)
Tezos Hands on 2019-06-15 (Japanese)Jun Furuse
 
Tezos and its formal verification (Japanese)
Tezos and its formal verification (Japanese)Tezos and its formal verification (Japanese)
Tezos and its formal verification (Japanese)Jun Furuse
 
Tezos hands-on : Tezos exercise
Tezos hands-on : Tezos exerciseTezos hands-on : Tezos exercise
Tezos hands-on : Tezos exerciseJun Furuse
 
Tezos hands-on : Tezos overview
Tezos hands-on : Tezos overviewTezos hands-on : Tezos overview
Tezos hands-on : Tezos overviewJun Furuse
 
Tezos: Self-amending crypt ledger (Japanese)
Tezos: Self-amending crypt ledger (Japanese)Tezos: Self-amending crypt ledger (Japanese)
Tezos: Self-amending crypt ledger (Japanese)Jun Furuse
 
ブロックチェーンと形式検証
ブロックチェーンと形式検証ブロックチェーンと形式検証
ブロックチェーンと形式検証Jun Furuse
 
Recent tezos core developments
Recent tezos core developmentsRecent tezos core developments
Recent tezos core developmentsJun Furuse
 
Challenges in blockchain certification (Nov 19, 2018 for TPP2018)
Challenges in blockchain certification (Nov 19, 2018 for TPP2018)Challenges in blockchain certification (Nov 19, 2018 for TPP2018)
Challenges in blockchain certification (Nov 19, 2018 for TPP2018)Jun Furuse
 
OCamlOScope: a New OCaml API Search
OCamlOScope: a New OCaml API SearchOCamlOScope: a New OCaml API Search
OCamlOScope: a New OCaml API SearchJun Furuse
 

More from Jun Furuse (18)

Tezos 008 Edo protocol
Tezos 008 Edo protocolTezos 008 Edo protocol
Tezos 008 Edo protocol
 
Plebeia, a new storage for Tezos blockchain state
Plebeia, a new storage for Tezos blockchain statePlebeia, a new storage for Tezos blockchain state
Plebeia, a new storage for Tezos blockchain state
 
Tezso and on-chain governanace: towards "Kyoto amendment"
Tezso  and on-chain governanace: towards "Kyoto amendment"Tezso  and on-chain governanace: towards "Kyoto amendment"
Tezso and on-chain governanace: towards "Kyoto amendment"
 
Comparison of Proof of Stakes
Comparison of Proof of StakesComparison of Proof of Stakes
Comparison of Proof of Stakes
 
SCaml compiler
SCaml compilerSCaml compiler
SCaml compiler
 
Blockchain and formal verification (Japanese)
Blockchain and formal verification (Japanese)Blockchain and formal verification (Japanese)
Blockchain and formal verification (Japanese)
 
Blockchain and Formal verification (English)
Blockchain and Formal verification (English)Blockchain and Formal verification (English)
Blockchain and Formal verification (English)
 
Tezos Hands on 2019-06-15 Exercise (Japanese)
Tezos Hands on 2019-06-15 Exercise (Japanese)Tezos Hands on 2019-06-15 Exercise (Japanese)
Tezos Hands on 2019-06-15 Exercise (Japanese)
 
Tezos Hands on 2019-06-15 (Japanese)
Tezos Hands on 2019-06-15 (Japanese)Tezos Hands on 2019-06-15 (Japanese)
Tezos Hands on 2019-06-15 (Japanese)
 
Tezos and its formal verification (Japanese)
Tezos and its formal verification (Japanese)Tezos and its formal verification (Japanese)
Tezos and its formal verification (Japanese)
 
Tezos hands-on : Tezos exercise
Tezos hands-on : Tezos exerciseTezos hands-on : Tezos exercise
Tezos hands-on : Tezos exercise
 
Tezos hands-on : Tezos overview
Tezos hands-on : Tezos overviewTezos hands-on : Tezos overview
Tezos hands-on : Tezos overview
 
Tezos: Self-amending crypt ledger (Japanese)
Tezos: Self-amending crypt ledger (Japanese)Tezos: Self-amending crypt ledger (Japanese)
Tezos: Self-amending crypt ledger (Japanese)
 
ブロックチェーンと形式検証
ブロックチェーンと形式検証ブロックチェーンと形式検証
ブロックチェーンと形式検証
 
Recent tezos core developments
Recent tezos core developmentsRecent tezos core developments
Recent tezos core developments
 
Challenges in blockchain certification (Nov 19, 2018 for TPP2018)
Challenges in blockchain certification (Nov 19, 2018 for TPP2018)Challenges in blockchain certification (Nov 19, 2018 for TPP2018)
Challenges in blockchain certification (Nov 19, 2018 for TPP2018)
 
OCamlOScope: a New OCaml API Search
OCamlOScope: a New OCaml API SearchOCamlOScope: a New OCaml API Search
OCamlOScope: a New OCaml API Search
 
Um2010
Um2010Um2010
Um2010
 

Recently uploaded

power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

SCaml compiler

  • 1. SCaml compiler DaiLambda, Inc. Jun FURUSE/古瀬淳 , Université de Paris, 2019-11-22Tezos Smart Contracts
  • 2. What is SCaml Yet another compiler from OCaml to Michelson. For Smart contracts Strict Subset of OCaml Small (< 3000 loc.). and Serious
  • 3. Strict Subset of OCaml No fancy features for smart contracts Many OCaml features are disabled: No recursion No polymoprhism No modules No objects No mutability No user defined types
  • 4. Small Built over OCaml’s compiler­libs. Reusing OCaml’s parser and type-checker, which are well tested for long time. SCaml code only compiles OCaml’s typed AST to Michelson. Less than 3000 lines of *.ml, written in 5 days.
  • 5. and Serious Serious compiler. Not a toy. All the Michelson opcodes are supported, except CREATE_CONTRACT. Some optimizations in the pure ML level. Babylon ready (i.e. entry points, closures)
  • 6. Benefit of being Strict Subset OCaml programmers can use SCaml without any surprise. Newbies can learn SCaml via OCaml tutorial. Many OCaml eco-system tools can be used for free: Menhir, Tuareg, indender, reformatter PPX, P4, ReasonML etc.
  • 7. Possibilities of being Strict Subset Contracts can be compiled to native code with a proper OCaml library: Fast Monte Carlo simulations of contracts. Contract, UI and server together in OCaml. “Ocsigen” for Tezos: Contracts: to Michelson by SCaml UI: to JS by JSOO Server: to native by OCaml
  • 8. Compilation path Parsing by OCaml parser Typing by OCaml type checker Unifying types for entry points and storage Translation to an IL, pure monomorhpic core ML Some inlining and partial evaluation Compilation to Michelson
  • 9. SCaml Features Numeric types: int, nat, tz Int (­12),   Nat 42,   Tz 1.23 with monomorphic operators: (+), (+^),(+$) Options, Lists, Sets, Maps: Some 1,   [ 1; 2; 3 ] Set [ 1; 2; 3 ],  Map [ (1, "one"), (2, "two") ] Blockchain related constants with strings: Key_hash "tz1..." Pairs, Sums: int * int,  (int, int) sum No user defined data types… yet Aliases are OK: type 'a t = (int * ('a, nat) sum)
  • 10. Future Work Pattern match (almost done) User defined types Nothing more. We keep things small.
  • 11. Vague Idea of Collaboration SCaml + ReFX = SCaml + refinement type Refinement specification as SCaml annotations. Compiles down them to annotations in Michelson.
  • 12. SCam Language A scam never calls it a scam. https://gitlab.com/dailambda/scaml