Skip to content

Instantly share code, notes, and snippets.

@hansallis
Forked from rupertlssmith/agenda.md
Created May 28, 2025 12:28
Show Gist options
  • Select an option

  • Save hansallis/f64102fd4def7d9f40a44b0cafc7d6f4 to your computer and use it in GitHub Desktop.

Select an option

Save hansallis/f64102fd4def7d9f40a44b0cafc7d6f4 to your computer and use it in GitHub Desktop.

Revisions

  1. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion agenda.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    3. This Gist - https://gist.github.com/rupertlssmith/9405d69acdf561a8b553450f7c5651db

    # Introductions/Motiviations
    * Undergrad final year project, Prolog compiler to bytecode, LLVM.
    * Undergrad final year project. Prolog compiler to bytecode, LLVM.
    * I want to learn more about the compiler code, intrigued about approach taken to extend by Lamdera.
    * Get more people involved.
    * No updates to Elm compiler since... Can we just use Lamdera in production instead?
  2. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    ## Resources
    1. https://github.com/lamdera/compiler
    2. https://github.com/rupertlssmith/lamdera-compiler/tree/exploration
    3. This Gist - https://gist.github.com/rupertlssmith/9405d69acdf561a8b553450f7c5651db

    # Introductions/Motiviations
    * Undergrad final year project, Prolog compiler to bytecode, LLVM.
  3. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    https://github.com/lamdera/compiler
    https://github.com/rupertlssmith/lamdera-compiler/tree/exploration
    ## Resources
    1. https://github.com/lamdera/compiler
    2. https://github.com/rupertlssmith/lamdera-compiler/tree/exploration

    # Introductions/Motiviations
    * Undergrad final year project, Prolog compiler to bytecode, LLVM.
  4. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    https://github.com/lamdera/compiler
    https://github.com/rupertlssmith/lamdera-compiler/tree/exploration

    # Introductions/Motiviations
    * Undergrad final year project, Prolog compiler to bytecode, LLVM.
    * I want to learn more about the compiler code, intrigued about approach taken to extend by Lamdera.
  5. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions haskell_elm.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    | Elm | Haskel |
    | ------- | ------ |
    | Elm | Haskel | |
    | ------- | ------ |-|
    | >> | Control.Arrow.>>> | |
    | << | . | Hmmm... |
    | |> | & | |
    | <| | $ | |
    | \|> | & | |
    | <\| | $ | |
    | : | :: | |
    | :: | : | Aaaghh! |
    | type ... | data ... |
    | type alias ... | type ... |
    | type ... | data ... | |
    | type alias ... | type ... | |
    | Debug.log label value | trace label value | Elm prints label and value, Haskell prints just label. Both take on value for the whole expression. |

    Elm:
  6. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 89 additions and 0 deletions.
    89 changes: 89 additions & 0 deletions haskell_elm.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    | Elm | Haskel |
    | ------- | ------ |
    | >> | Control.Arrow.>>> | |
    | << | . | Hmmm... |
    | |> | & | |
    | <| | $ | |
    | : | :: | |
    | :: | : | Aaaghh! |
    | type ... | data ... |
    | type alias ... | type ... |
    | Debug.log label value | trace label value | Elm prints label and value, Haskell prints just label. Both take on value for the whole expression. |

    Elm:

    length : List a -> Int
    length l =
    case l of
    [] -> 0
    x :: xs -> 1 + length xs

    Haskell:

    length :: [a] -> Int
    length [] = 0
    length (x:xs) = 1 + length xs

    Elm:

    filter : (a -> Bool) -> List a -> List a
    filter isGood list =
    foldr (\x xs -> if isGood x then cons x xs else xs) [] list

    Haskell:

    filter :: (a -> Bool) -> [a] -> [a]
    filter pred [] = []
    filter pred (x:xs)
    | pred x = x : filter pred xs
    | otherwise = filter pred xs


    Elm:

    map5 :
    (a -> b -> c -> d -> e -> result)
    -> Task x a
    -> Task x b
    -> Task x c
    -> Task x d
    -> Task x e
    -> Task x result
    map5 func taskA taskB taskC taskD taskE =
    taskA
    |> andThen
    (\a ->
    taskB
    |> andThen
    (\b ->
    taskC
    |> andThen
    (\c ->
    taskD
    |> andThen
    (\d ->
    taskE
    |> andThen (\e -> succeed (func a b c d e))
    )
    )
    )
    )

    Haskell:

    map5 ::
    (a -> b -> c -> d -> e -> result) ->
    Task x a ->
    Task x b ->
    Task x c ->
    Task x d ->
    Task x e ->
    Task x result
    map5 func taskA taskB taskC taskD taskE = do
    a <- taskA
    b <- taskB
    c <- taskC
    d <- taskD
    e <- taskE
    pure $ func a b c d e

  7. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion agenda.md
    Original file line number Diff line number Diff line change
    @@ -25,4 +25,5 @@ What compiler ideas do you have and would they fit into Lamdera?

    * AI code chunking.
    * Recent Language Server announced on Slack.
    * New compiler targets - JVM, LLVM, WASM, ...
    * New compiler targets - JVM, LLVM, WASM, ...
    * Parser with full error recovery.
  8. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    # Introductions/Motiviations
    * Undergrad final year project, Prolog compiler to bytecode, LLVM.
    * I want to learn more about the compiler code, intrigued about approach taken to extend by Lamdera.
    * Get more people involved.
    * No updates to Elm compiler since... Can we just use Lamdera in production instead?
    * New backends, Elm to good to just be used for UI work, really strong affinity to domain modelling. Elms type system, and package system with semantic versioning, should be at the heart of enterprise systems, not just the edges.

  9. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    # Introductions/Motiviations
    * Undergrad final year project, Prolog compiler to bytecode, LLVM.
    * I want to learn more about the compiler code, intrigued about approach taken to extend by Lamdera.
    * No updates to Elm compiler since... Can we just use Lamdera in production instead?
    * New backends, Elm to good to just be used for UI work, really strong affinity to domain modelling. Elms type system, and package system with semantic versioning, should be at the heart of enterprise systems, not just the edges.

    # First Half - Build Instructions
    * Walk through of setup and build of Lamdera.
    * Building standalone distribution.
  10. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions replacement_compiler.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # Can Lamdera run as a drop-in replacement for Elm?

    I turned the standard "Counters" Elm program into a Lamdera program. I gave it entry points `main` for standard Elm, and `app` for Lamdera.

    Trying to build it as an Elm program yields something that does not run as a standalone Elm web app:

    cd test-program
    lamdera make src/Frontend.elm
    python3 -m http.server 8000

    But it will run under Lamdera live:

    lamdera live

    Can I use Lamdera as a drop-in replacement to build a standard Elm program? Its certainly not far off being able to do so, unsure if I just need the right config or would require a little bit of code modification to achieve this.
  11. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 3 changed files with 66 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions build_with_cabal.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Build it with Cabal:

    Mario advises against building with Cabal as managing dependencies and upgrades to them is a pain. But for completeness lets try it.

    These build steps were extracted from the `distribution/docker/x86_64-musl.dockerfile`. There are already scripts under `distribution/` folder to build for many different platforms. This is probably the easiest way
    of doing it. But here is a more epxlicit step by step way for a Linux box.

    Not that compared with the Dockerfile I had to remove static linking, it has `CABALOPTS="-f-export-dynamic -fembed_data_files --enable-executable-static -j4"`. Making a more portable statically linked binary is a bit tricky with Haskell, and that is why the Dockerfile builds on Alpine Linux to do that since it uses musl libc
    which is a more standalone libc.

    curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
    export PATH="${PATH}:~/.ghcup/bin"

    ghcup install ghc 9.2.8 --set
    ghcup install cabal 3.10.1.0 --set
    cabal update

    export CABALOPTS="-f-export-dynamic -fembed_data_files -j4"
    export GHCOPTS="-j4 +RTS -A256m -RTS -split-sections -optc-Os -optl=-pthread"

    cabal build $CABALOPTS --ghc-options="$GHCOPTS" --only-dependencies
    cabal build $CABALOPTS --ghc-options="$GHCOPTS"
    23 changes: 23 additions & 0 deletions build_with_stack.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # Build it with Stack:

    Haskell has build systems called Cabal and Stack. Stack is more modern and builds on top of Cabal and is the recommended way to build Lamdera. The original Elm compiler only has a Cabal build.

    On Debian I was able to install Stack through the package manager:

    sudo apt-get install haskell-stack
    sudo stack upgrade

    Alternatively there are install scripts:

    curl -sSL https://get.haskellstack.org/ | sh

    One thing I noticed is that when running `stack ghci` it downloaded ghc-tinfo6-9.8.4, which must be the ghc compiler itself, but what is the tinfo6 bit? Stack overflow answer: "It is a GHC build variant that links to libtinfo.so.6 (as opposed to linking to some version of libncurses)". So seems like Stack itself knows which compiler version it needs and takes care of fetching it.

    Creating a compiler binary is as simple as:

    stack install

    If you just want to build it, then run it without installing:

    stack build
    stack exec lamdera
    21 changes: 21 additions & 0 deletions ide_setup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Working with Hasell in IDE. ghcup, hls, Visual Studio

    Install GHCup, and installer program for ghc, cabal and hls that will manage
    versions also:

    https://www.haskell.org/ghcup/

    Visual Studio plugin for Haskell:

    https://marketplace.visualstudio.com/items?itemName=haskell.haskell#setup

    Installed the VS plugin via View -> Extensions -> Haskell. Once this was installed it prompted me to install hls via ghcup and did so automatically.

    It seems to work better if you run vscode from the folder where you checked out Lamdera:

    cd projects/lamdera-compiler
    code .

    Now file navigation seems to find things better.

    I don't know why but vscode did something weird with formatting Haskell on save. Press cmd + shift + p then search for "save without formatting" and click on the configure icon, then bind it with 'cmd + s'.
  12. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 2 changed files with 22 additions and 21 deletions.
    21 changes: 0 additions & 21 deletions build_with_stack.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    Haskell has build systems called Cabal and Stack. Stack is more modern and builds on top of Cabal and is the recommended way to build Lamdera. The original Elm compiler only has a Cabal build.

    On Debian I was able to install Stack through the package manager:

    sudo apt-get install haskell-stack
    sudo stack upgrade

    Alternatively there are install scripts:

    curl -sSL https://get.haskellstack.org/ | sh

    One thing I noticed is that when running `stack ghci` it downloaded ghc-tinfo6-9.8.4, which must be the ghc compiler itself, but what is the tinfo6 bit? Stack overflow answer: "It is a GHC build variant that links to libtinfo.so.6 (as opposed to linking to some version of libncurses)". So seems like Stack itself knows which compiler version it needs and takes care of fetching it.

    Creating a compiler binary is as simple as:

    stack install

    If you just want to build it, then run it without installing:

    stack build
    stack exec lamdera
    22 changes: 22 additions & 0 deletions get_and_compare_code.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Get the code and compare with the original:

    Get the Lamdera code, and required git submodules.

    mkdir -p lamdera/lamdera
    git clone https://github.com/lamdera/compiler.git lamdera/lamdera/

    cd lamdera/lamdera
    git submodule init && git submodule update

    Get the Elm compiler code (because it will be informative to compare):

    mkdir -p elm/compiler
    git clone https://github.com/elm/compiler.git elm/compiler/

    Compare the codebases:

    kdiff3 lamdera/lamdera elm/compiler

    Find alternative implementations:

    find builder/ compiler/ -name '*.hs' | xargs grep 'alternativeImplementation'
  13. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions build_with_stack.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    Haskell has build systems called Cabal and Stack. Stack is more modern and builds on top of Cabal and is the recommended way to build Lamdera. The original Elm compiler only has a Cabal build.

    On Debian I was able to install Stack through the package manager:

    sudo apt-get install haskell-stack
    sudo stack upgrade

    Alternatively there are install scripts:

    curl -sSL https://get.haskellstack.org/ | sh

    One thing I noticed is that when running `stack ghci` it downloaded ghc-tinfo6-9.8.4, which must be the ghc compiler itself, but what is the tinfo6 bit? Stack overflow answer: "It is a GHC build variant that links to libtinfo.so.6 (as opposed to linking to some version of libncurses)". So seems like Stack itself knows which compiler version it needs and takes care of fetching it.

    Creating a compiler binary is as simple as:

    stack install

    If you just want to build it, then run it without installing:

    stack build
    stack exec lamdera
  14. @rupertlssmith rupertlssmith revised this gist May 27, 2025. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion agenda.md
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,19 @@
    * Building standalone distribution.
    * IDE setup.

    Do people want to follow along on their own machines and work through the setup and build together?
    What platforms do we have? Mac, Linux, Windows...

    # Second Half - Code Exploration
    * Haskell vs Elm to help us reading Haskell.
    * Diff Lamdera and Elm.
    * Compiler model and code tour.
    * Can Lamdera run as a drop-in replacement for Elm?
    * Your ideas, how would they fit into Lamdera.

    ## Ideas

    What compiler ideas do you have and would they fit into Lamdera?

    * AI code chunking.
    * Recent Language Server announced on Slack.
    * New compiler targets - JVM, LLVM, WASM, ...
  15. @rupertlssmith rupertlssmith revised this gist May 26, 2025. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@
    # 8pm Build Instructions
    # First Half - Build Instructions
    * Walk through of setup and build of Lamdera.
    * IDE setup.
    * Building standalone distribution.
    * IDE setup.

    # 9pm Code Exploration
    # Second Half - Code Exploration
    * Haskell vs Elm to help us reading Haskell.
    * Diff Lamdera and Elm.
    * Compiler model and code tour.
    * Can Lamdera run as a drop-in replacement for Elm?
    * Your ideas, how would they fit into Lamdera.
  16. @rupertlssmith rupertlssmith revised this gist May 26, 2025. 2 changed files with 10 additions and 1 deletion.
    10 changes: 10 additions & 0 deletions agenda.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # 8pm Build Instructions
    * Walk through of setup and build of Lamdera.
    * IDE setup.
    * Building standalone distribution.

    # 9pm Code Exploration
    * Haskell vs Elm to help us reading Haskell.
    * Diff Lamdera and Elm.
    * Compiler model and code tour.
    * Your ideas, how would they fit into Lamdera.
    1 change: 0 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    # test
  17. @rupertlssmith rupertlssmith renamed this gist May 26, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  18. @rupertlssmith rupertlssmith created this gist May 26, 2025.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # test