The main motivation behind Yolc is to strike a balance between the following values for building Ethereum smart contracts:
Safe
Yolc is purely functional with linear type safety, made for the Ethereum virtual machine.
What does purely functional linear type safety mean here? Read more here.
Expressive
Yolc embeds itself in the Haskell language before being compiled into Solidity/Yul code.
Why does expressiveness matter? Read more here.
Fun
Yolc allows you to write safe code in production, a joyful experience for super coders.
Check out these example codes.
Tip
Yolc is a compiler program for "YulDSL/Haskell". YulDSL is a domain-specific language (DSL) based on category theory for Solidity/Yul. YulDSL can be embedded in different languages, with "YulDSL/Haskell" being the first of its kind. Curiously, the name "yolc" sounds similar to "solc", the compiler program for "Solidity/Yul".
Do not worry if you don't understand some of these concepts, you can start with Yolc right away and have a rewarding, fun experience writing safer production smart contracts. However, if you do feel adventurous and want to delve into the inner workings of YulDSL, read here.
Caution
π§ While this project is still work in progress π§, the good news is after pausing for the good part of 2024 due to business reason, I am back to it. As of 2024 October, the end-to-end is working and I have adjusted the roadmap and planned an exciting type system for the first release!
Contact me at [email protected] if you are interested in testing this project out soon!
Note
These include Ethereum contract ABI specification implemented in as core types, their type extensions, including dependently typed extensions.
Unlike solidity, and to accommodate Haskell lexical rules, types are all in capitalize letters:
- Boolean type
BOOL
, and its valuestrue
,false
. - Address type
ADDR
. - Integers types:
I8
,I16
, ...I256
;U8
,U16
, ...U256
. - etc.
Full table of the types implemented and planned can be found here.
Haskell Native Syntax
TODO.
Currying Function Definition
-- define a pure value function
foo3 = fn @(Maybe U8 -> Maybe U8 -> Maybe U8 -> Maybe U8) "foo3"
\a b c -> a + b + c
-- call other pure value function
call3 = fn @(Maybe U8 -> Maybe U8) "call3"
\a -> call foo3 a a a
Pattern Matching
add_maybe_int96_with_default = fn @(I96 -> I96 -> I96 -> I96) "add_maybe_int96_with_default"
\x y def -> match (inCase (Just x) + inCase (Just y)) \case
Nothing -> def
Just z -> z
TODO.
TODO.
- eth-abi - Ethereum contract ABI specification in Haskell
- yul-dsl - A DSL for Solidity/Yul
- yul-dsl-linear-smc - Embedding YulDSL in Haskell Using Linear Types
- yol-suite - A Collection of YulDSL Programs for the New Pioneer of Ethereum Smart Contracts Development
Warning
YOU DON'T NEED TO LOOK AT THIS DIRTY LAUNDRY!
Legend for items:
- β,π - Highlighted feature.
- π’ - Planned and low uncertainty;
- π - Planned with some design decisions to be made;
- π΄ - Likely deferred to the future versions;
- β - To be reviewed.
TODOs for 0.1.0.0
- eth-abi
- CoreType
- NP (N-ary Product, type-level recursive-friendly alternative to tuple type)
- BOOL
- INTx s n
- BYTESn
- ADDR
- CoreType
- yul-dsl
- YulCat
- Value functions
- All integer number types: U8, U16.. U256; I8, I16, .. I256.
- All fixed size bytes types: B1, B2... B32.
- π§ β Safe number handling with
- checked number operations,
- number operations over optional values,
- pattern matching of optional (Haskell
Maybe
type) values - type-safe upCast, and safeCast to optional values.
- π’
YulCast
, casting values between value types. - π’ All
Num
andMaybe Num
built-ins
- yulKeccak256 for supported types.
- Side Effects
-
YulSGet
,YulSPut
for raw storage operations. - [x]
YulCall
, external function calls.
-
- Exceptions
-
revert0
, solidity-equivalent ofrevert()
-
- Control flows
- Haskell native if-then-else expression through "RebindableSyntax".
- β Pattern matching support of optional number values.
- Yul Object
- Function export modifiers resembling solidity:
pureFn, staticFn, externalFn
.
- Function export modifiers resembling solidity:
- Type safety
- Type-level purity classification:
IsEffectNotPure, MayEffectWorld
.
- Type-level purity classification:
- Value functions
- Built-in Yul Functions Infrastructure
- π§ π’ Full arithmetic support
- π§ π’ Full ABICodec support
- Working with pure effect
- Build pure functions
fn
.β οΈ This will be replaced with$fn
. - Call pure functions
callFn
.
- Build pure functions
- CodeGen
- Yul code generator for any YulCat
- Yul object dispatcher generator for exported functions.
- Evaluator
evalFn
to evaluateFn
(single YulCat value styled as a function) value.
- YulCat
- yul-dsl-linear-smc
- πππ Linear safety for side effects
- Compile expression sof linear data ports to YulCat
- Working with versioned data port through
YulMonad
, a "Linearly Versioned Monad." - Build linear functions with
lfn
.β οΈ This will be replaced with$yulMonadV, $yulMonadP
. - Call functions linearly with
callFn'l
,callFn'lpp
.`
- Working with data ports
- π’ match'l for pattern matching data ports.
- π’ ifThenElse through pattern matching on BOOL data port.
- π’ Num classes for data ports: mul, abs, sig, etc.
- Working with storage:
- π’ Low-level storage functions for input data ports,
sget, sput
.
- π’ Low-level storage functions for input data ports,
- πππ Linear safety for side effects
- yol-suite
- YOLC
- Singleton program factory
- Program interface, e.g.
interface IERC20Program
- Program factory, e.g.
function createERC20Program()
- Program interface, e.g.
- Contract verification support
- π’ EIP-1967 compatible "stunt contract" generator. A stunt contract includes both:
- the program's interface necessary to interact with the program via EIP-1967-aware explorers,
- a copy of Haskell main source code in a block of solidity comments.
- π’ EIP-1967 compatible "stunt contract" generator. A stunt contract includes both:
- Singleton program factory
- CLI
- β
yolc
, a MVP in shells script, prepares YOLC project and invoke YOLC builder.
- β
- Developer communication
- Annotated ERC20 demo
- Software distributions
- Nix flake
- π’ Rudimentary github dev console
- YOLC
TODOs for 0.2.0.0
- eth-abi
- CoreType
- π ARRAY a
- π BYTES
- π STRING
- ExtendedType
- π REF, storage or memory reference
- π SELECTOR
- π TUPLEn, STRUCT with named fields, etc.
- ABICodec
- π’ Compatibility with the solidity abi-spec
- CoreType
- yul-dsl
- YulCat
- Value functions
- π’ yulKeccak256 evaluation function using ABICodec from eth-abi.
- π’ array length built-in.
- π Maybe support of non word values.
- Exceptions
- π’
revertWithError
- π’
revertWithMessage
- π’
- Control flows
- π
YulMapArray
, tight loop over an array.
- π
- Yul object
- Side Effects
- π’
YulStaticCall
, static external calls. - π’
YulDelegateCall
, delegate external calls.
- π’
- Type safety
- β further encode total functions in type
- Value functions
- Working with pure effect
- π
$fn
template haskell for generating automatic unique function id.
- π
- CodeGen
- Function Gen:
- π Fix the implementation for all embeddable values.
- Object builder:
- π constructor support.
- Function Gen:
- Evaluator
- π’ handling exception
- π’ test coverage, and check against foundry results
- YulCat
- yul-dsl-linear-smc
- Working with versioned data port through
YulMonad
, a "Linearly Versioned Monad."- π’ Build YulMonad functions:
$yulMonadV
for versioned inputs, and$yulMonadP
for pure inputs. - π Storage functions working with
Referenceable
types.
- π’ Build YulMonad functions:
- Working with versioned data port through
- yol-suite
- YOLC
- π Solidity struct generator for types.
- Advanced program deployment strategy:
- π manual logic split through delegateCall.
- π΄ auto logic split & dispatching,
- π΄ Shared library.
- Program upgradability:
- π Beacon upgradability.
- Contract verification support
- π΄ Full stunt contract generator.
- CLI
- π΄ Use 'THSH' to mix shell scripting and publish its haskell binary.
- Developer communication
- Software distributions
- better github dev console
- yolc.dev playground
- YOLC
- attila
- Test Pipeline:
attila test
- π Foundry testing integration using stunt contract.
- π΄ QuickCheck integration using Eval monad.
- Deployment Pipeline:
attila deploy
- π Deploy the program (program is an unit of deployment.)
- π΄ Etherscan verification pipeline.
- Test Pipeline:
- drwitch
- ...
Big Features In Research
- Linearly Versioned Monad, comparing to other resource management method including monadic regions, CoDensity, etc.
- Liquid haskell integration.
- Dependently extended types.
- Portable YulDSL artifact for non-Haskell language embedding and cross-languages modules.