Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Spice syntax for variants with argument

$
0
0

Okay so I understand from docs/GUIDE.md in https://www.npmjs.com/package/@greenlabs/ppx-spice/v/0.1.15?activeTab=code
that I can use:

// generates the functions gameId_encode() and gameId_decode()
@spice
type gameId = string

// generates the functions t_encode() and t_decode()
@spice
type t =
  | StandAlone
  | Master(gameId)
  | Slave(gameId)

Then the values with arguments are apparently encoded as arrays:

["Master", "gameId"]

But now that I run the compiler (rescript) I’m getting:

rescript: [178/268] src/modules/GameTypeCodec-Salem1692.cmj
FAILED: src/modules/GameTypeCodec-Salem1692.cmj

  We've found a bug for you!
  /Users/ruittenb/Desktop/projects/salem-1692/src/modules/GameTypeCodec.res

  The variant constructor Function$ can't be found.

  - If it's defined in another module or file, bring it into scope by:
    - Prefixing it with said module name: TheModule.Function$
    - Or specifying its type: let theValue: TheModule.theType = Function$
  - Constructors and modules are both capitalized. Did you want the latter?
    Then instead of let foo = Bar, try module Foo = Bar.

I’m getting it for every Codec, and I have no idea what this means or how to solve it. Anyone?

Thanks in advance,
René


Viewing all articles
Browse latest Browse all 2592

Trending Articles