From 7f8f57f9539a61a4f0bd04d4e8d82ac7063faee6 Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Sat, 16 Dec 2023 22:52:05 +0000 Subject: [PATCH] Readme --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 2 +- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f3a4feea..b8e808b0 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,52 @@ Like [llvm-calc](https://github.com/danieljharvey/llvm-calc), but adapting it for learning WASM. -https://github.com/danieljharvey/llvm-calc +Each directory slowly adds features to a calculator that compiles to WASM. + +## wasm-calc + +Simple numerical expressions + +`1 + 2 + 3 * 3` + +## wasm-calc2 + +Basic if expressions + +`if 1 == 2 then 7 else 8` + +## wasm-calc3 + +Simple functions + +``` +function sum(a: Integer, b: Integer) { + a + b +} + +sum(1,2) +``` + +## wasm-calc4 + +Simple compound types (tuples). + +``` +function swapPair(pair: (Integer, Boolean)) { + (pair.2, pair.1) +} + +if swapPair((100,True)).1 then 7 else 8 +``` + +## wasm-calc5 + +Floats, use different WASM types + +``` +function sumPair(pair: (Float,Float)) { + pair.1 + pair.2 +} + +sumPair((100.0,200.0)) +``` diff --git a/flake.nix b/flake.nix index 857504d5..56978913 100644 --- a/flake.nix +++ b/flake.nix @@ -58,7 +58,7 @@ buildInputs = with haskellPackages; [ hlint ormolu - # haskell-language-server # this simply does nothing atm + haskell-language-server ghcid cabal-fmt cabal-install