#Piping into `result.try`

1 messages · Page 1 of 1 (latest)

shut bone
#

Is there a better way to write this?

use happy_path_value <-
    do_stuff()
    |> result.replace_error(MyErrorVariant)
    |> fn(x) { result.try(x, _) }

I don't like writing the fn in there.

nova abyss
#

I would generally write it like this:

import result.{try}

// ...

use happy_path_value <- try(
    do_stuff()
    |> result.replace_error(MyErrorVariant)
)
shut bone
#

oh nice

#

yea that works

#

so basically, "don't pipe into result.try"

buoyant steppe
#

You can pipe into result.try

#

You can't pipe into use