GithubHelp home page GithubHelp logo

lamdera-issue's Introduction

Lamdera type safety issue

This repository shows how it is possible to create a lamdera app which compiles but sends incorrect messages from backend to frontend.

Model is defined as following:

type ToFrontend
    = ServerState SharedState


type SharedState
    = Lobby Int
    | NotLobby

Then we are trying to broadcast the state to clients using this code:

updateClients : Model -> Cmd BackendMsg
updateClients m =
    Lamdera.broadcast (Lobby (Set.size m.clients))

Which is incorrect, since it should be SharedState (Lobby (Set.size m.clients)), but the code compiles and we have undefined behaviour. The message from bakend is descoded as NotLobby shared state.

You can see the behaviour in action by checking out this repository, running lamdera live and opening http://localhost:8000 in the browser.

You can also see it on this screenshot:

Screenshot

Environment:

Linux minty 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
➜  lamdera-issue git:(master) ✗ lamdera --version
0.0.1-alpha8-0.19.0
➜  lamdera-issue git:(master) ✗ 

lamdera-issue's People

Contributors

kenota avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.