Giter VIP home page Giter VIP logo

Comments (3)

robinheghan avatar robinheghan commented on August 10, 2024 1

@alexislozano Gren doesn't have tuples. Use Unit instead of the empty tuple, and { model = ..., command ... } for the init and update return values.

from core.

alexislozano avatar alexislozano commented on August 10, 2024 1

For other contributors, here's the compiling gren code:

module Main exposing (..)

import Html exposing (text)
import Process
import Task exposing (Task)
import Browser


killProcessTwice : Task Never Unit
killProcessTwice =
    Task.succeed Unit
        |> Process.spawn
        |> Task.andThen
            (\pid ->
                Process.kill pid
                    |> Task.andThen (\_ -> Process.kill pid)
            )


main =
    Browser.element
        { init = \Unit ->
            { model = Unit
            , command = Task.perform (always Unit) killProcessTwice
            }
        , view = \_ -> text "oops"
        , update = \_ model -> { model = model, command = Cmd.none }
        , subscriptions = \_ -> Sub.none
        }

from core.

alexislozano avatar alexislozano commented on August 10, 2024

@lue-bird When I try to compile with gren the example given in the linked issue:

module Main exposing (..)

import Html exposing (text)
import Process
import Task exposing (Task)
import Browser


killProcessTwice : Task Never ()
killProcessTwice =
    Task.succeed ()
        |> Process.spawn
        |> Task.andThen
            (\pid ->
                Process.kill pid
                    |> Task.andThen (\_ -> Process.kill pid)
            )


main =
    Browser.element
        { init = \() ->
            ( ()
            , Task.perform (always ()) killProcessTwice
            )
        , view = \_ -> text "oops"
        , update = \_ model -> (model, Cmd.none)
        , subscriptions = \_ -> Sub.none
        }

I get an error about empty tuples:

$ gren make src/Main.gren 
Detected problems in 1 module.
-- PROBLEM IN TYPE ANNOTATION ------------------------------------ src/Main.gren

I was partway through parsing the `killProcessTwice` type annotation, but I got
stuck here:

9| killProcessTwice : Task Never ()
                                  ^
I was expecting to see a type next. Try putting Int or String for now?

Do you know what could be happening?

from core.

Related Issues (20)

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.