purescript / roadmap

Long-term projects not covered by other issues lists
20 stars 1 forks source link

Either FFI extensions #47

Closed texastoland closed 8 years ago

texastoland commented 8 years ago

Conveniences for handling JavaScript exceptions and Node thunks. Inspired by Result from the Swift community. Originally suggested by @archaeron in paf31/purescript-preface#1.

zudov commented 8 years ago

I'll just drop a reference to Elm's Result as an additional source of inspiration http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Result

zudov commented 8 years ago

Although, it has nothing to do with exceptions and thunks, only the friendlier naming.

paulyoung commented 8 years ago

Here's my F# version, for reference: https://github.com/functionauts/Result

texastoland commented 8 years ago

@zudov Yeah Elm uses Result as an alias for Either. Likewise formatError looks like lmap. to/fromMaybe would be nice though! Ultimately we want an alternate prelude with beginner friendly naming too. But referencing a couple Swift implementations I noticed they took it a step further to encapsulate error handling.

@paulyoung Thanks! Very succinct and reassuring this is low hanging fruit. What's the use case for dematerialize?

paulyoung commented 8 years ago

@AppShipIt it's equivalent to dematerialize in antitypical/Result but I only really added it for interop with C# where an exception is expected to be thrown.

texastoland commented 8 years ago

Totally missed that thanks! May as well add for parity.

paf31 commented 8 years ago

This seems like something which belongs in a user library, but not necessarily the core libraries. Automatic handling of exceptions is not the sort of "opinionated" (if you like) approach taken by core libraries.

Sent from my iPhone

On Feb 22, 2016, at 7:50 AM, Texas Toland notifications@github.com wrote:

Totally missed that thanks!

— Reply to this email directly or view it on GitHub.

texastoland commented 8 years ago

Ah didn't realize it was necessarily for core stuff (likewise #45). I opened the issue as a personal todo unless someone else wants to. Clarify opinionated? My idea was vaguely motivated by Harry's Eff functions. I just want to be able to consume an exception-al JS thing and not crash PS.

texastoland commented 8 years ago

Better implemented as an extension to Either with the Result nomenclature in Preface eventually. Closing as more of a community effort than necessarily official for the time being.