Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected type ... SketchError ... found type ... Error on tardis 0.2 #6

Open
edman opened this issue Oct 8, 2024 · 2 comments
Open

Comments

@edman
Copy link

edman commented Oct 8, 2024

I get build errors in my app on gleam run -m lustre/dev build after updating tardis to 0.2.

  Compiling tardis
error: Type mismatch
    ┌─ /client/build/packages/tardis/src/tardis.gleam:134:17
    │
134 │   |> result.try(start_lustre(lustre_root, _))
    │                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected type:

    fn(App(Nil, Model, Msg)) ->
      Result(fn(Action(Msg, ClientSpa)) -> Nil, SketchError)

Found type:

    fn(App(Nil, Model, Msg)) -> Result(fn(Action(Msg, ClientSpa)) -> Nil, Error)

It looks like gleam's type checker infers different types for sketch.cache depending on the target.

This returns a Result(Cache, a)
https://github.com/ghivert/sketch/blob/main/sketch/src/sketch.gleam#L77

While this returns a Result(Cache, SketchError)
https://github.com/ghivert/sketch/blob/main/sketch/src/sketch.gleam#L88

@ghivert
Copy link
Owner

ghivert commented Oct 13, 2024

Hi!
Could you show your start_lustre function?

@brettcannon
Copy link

I'm seeing the same error:

error: Type mismatch
    ┌─ /home/brett/Repositories/brettcannon/choose-a-font.dev/build/packages/tardis/src/tardis.gleam:134:17
    │
134 │   |> result.try(start_lustre(lustre_root, _))
    │                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected type:

    fn(App(Nil, Model, Msg)) -> Result(fn(Action(Msg, lustre.ClientSpa)) -> Nil, error.SketchError)

Found type:

    fn(App(Nil, Model, Msg)) -> Result(fn(Action(Msg, lustre.ClientSpa)) -> Nil, error.Error)

I'm using lustre.simple() and launching using gleam run -m lustre/dev start.

And my start_lustre function from tardis.gleam is:

fn start_lustre(lustre_root, application) {
  application
  |> lustre.start(lustre_root, Nil)
  |> result.map_error(error.LustreError)
}

This is with:

  • lustre 4.6.3
  • lustre_dev_tools 1.6.2
  • tardis 0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants