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

Types with lists are wrong for Elm #193

Open
nikitaDanilenko opened this issue Aug 29, 2022 · 0 comments
Open

Types with lists are wrong for Elm #193

nikitaDanilenko opened this issue Aug 29, 2022 · 0 comments

Comments

@nikitaDanilenko
Copy link
Contributor

nikitaDanilenko commented Aug 29, 2022

When a type contains a list of values, the generated encoder for Elm is wrong.
The reason is that the type of Encode.list is

Encode.list: (a -> Value) -> List a -> Value

but it is used with an encoder myEncoder: a -> Value in the following construct

Encode.list (List.map myEncoder listOfA)

which is a type error.

Reconstruction

import bridges.core.syntax._
import bridges.elm.Elm

object Issue {

  case class Child(
      number: Int
  )

  case class Parent(
      children: List[Child]
  )

  def main(args: Array[String]): Unit = {
    val (_, content) = Elm.buildFile(
      module = "TestModule",
      decls = List(
        decl[Child],
        decl[Parent]
      ),
      customTypeReplacements = Map.empty
    )
    println(content)
  }

}

The List.map needs to be removed entirely, which fixes the issue.

nikitaDanilenko added a commit to nikitaDanilenko/bridges that referenced this issue Aug 29, 2022
nikitaDanilenko added a commit to nikitaDanilenko/bridges that referenced this issue Aug 29, 2022
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

1 participant