Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.
This repository was archived by the owner on May 2, 2024. It is now read-only.

Usage in Rescript #30

Description

@ethanabrooks

HI,
I am a little new to Rescript. I am trying to reproduce the example in your README in Rescript. This is as far as I got:

module Option = {
  let let_ = Belt.Option.flatMap
}

type address = {street: option<string>};

type personalInfo = {address: option<address>};

type user = {info: option<personalInfo>};

// Get the user's street name from a bunch of nested options. If anything is
// None, return None.
let getStreet = (maybeUser: option<user>): option<string> => {
  let%Option user = maybeUser;
  // Notice that info isn't an option anymore once we use let%Option!
  let%Option info = user.info;
  let%Option address = info.address;
  let%Option street = address.street;
  Some(street->Js.String.toUpperCase);
};

I am getting:

  141 │   let%Option info = user.info;
  142 │   let%Option address = info.address;
->143 │   let%Option street = address.street;
  144 │   Some(street->Js.String.toUpperCase);
  145 │ };
  
  Did you forget a `=` here?

FAILED: cannot make progress due to previous errors.
>>>> Finish compiling(exit: 1)

I assume the let% syntax has to change somehow for rescript?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions