Skip to content

Duplicate definition in Codec for shared types #3

@alltonp

Description

@alltonp

Hi,

I've been using scala-elm-types for a while and it's been working very nicey, it's awesome not having to handcode encoders and decoders :)

However, I've hit a snag when case classes share the same type, for example:

case class Ball(name: String)

sealed trait ClientToServer
case class Ping(message: String, ball: Ball) extends ClientToServer

sealed trait ServerToClient
case class Pong(message: String, ball: Ball) extends ServerToClient

The Ball type (and its encoder/decoder) are generated twice (see errors below)

Is there anyway to prevent this?

Many thanks,
Paulos


-- DUPLICATE DEFINITION -------------------------------------------- ./Codec.elm

Naming multiple top-level values `decodeBall` makes things ambiguous. When you
say `decodeBall` which one do you want?

48| decodeBall =
    ^^^^^^^^^^
Find all the top-level values named `decodeBall` and do some renaming. Make sure
the names are distinct!

-- DUPLICATE DEFINITION -------------------------------------------- ./Codec.elm

Naming multiple top-level values `encodeBall` makes things ambiguous. When you
say `encodeBall` which one do you want?

64| encodeBall obj = Encode.object
    ^^^^^^^^^^
Find all the top-level values named `encodeBall` and do some renaming. Make sure
the names are distinct!

-- DUPLICATE DEFINITION -------------------------------------------- ./Codec.elm

Naming multiple top-level values `Ball` makes things ambiguous. When you say
`Ball` which one do you want?

9| type alias Ball = { name : String }
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Find all the top-level values named `Ball` and do some renaming. Make sure the
names are distinct!

-- DUPLICATE DEFINITION -------------------------------------------- ./Codec.elm

There are multiple types named `Ball` in this module.

9| type alias Ball = { name : String }
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Search through this module, find all the types named `Ball`, and give each of
them a unique name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions