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
\account'p mintAmount'p -> LVM.do
-- fetch balance of the account
(account'p, balanceBefore) <- pass account'p balance_of
-- use linear port (naming convention, "*'p") values safely
(account'p, mintAmount'p) <- passN_ (account'p, mintAmount'p) \(account'p, mintAmount'p) ->
-- update balance
sput (balance_sloc account'p) (balanceBefore + ver'l mintAmount'p)
-- call unsafe external contract onTokenMinted
externalCall onTokenMinted (ver'l account'p) (ver'l mintAmount'p)
Yolc leverages the power of the best toolking in the ecosyste, while focusing on what it is best at: a safe, expressive and fun programming language. It is not a full toolkit for Ethereum development. Hence, it is recommended to work in tandem with the foundry toolkit.
- 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
- yolc: the evil twin of "solc"; this is the compiler program for "YulDSL/Haskell".
- attila: who wields the foundy, forges his path; this is the counter part of the "forge" from foundry. However, it mostly invokes directly "forge" for you, since yol-suite integrates itself with the foundry toolkit.
- drwitch: who persuades the tyrant, shapes our history; this is the counter part of the "cast" from foundry.
For the ongoing feature development, here is the ccomplete todo list.
- 🚧 Jan 6th, 2025: public announcement, with the first technical release (unversioned).
- End of Jan 2025: version 0.0.1.0 with major features completion.
- End of Feb 2025: version 0.0.2.0 with first live in production projects.
- ...
- A paper on the linearly versioned monad, the corner stone of the yolc linear safety, as a survey of comparing it to other resource management method including monadic regions, CoDensity, etc.
- Liquid haskell integration.
- Extend core types through dependent types.
- Portable YulDSL artifact for non-Haskell language embedding and cross-languages modules.