documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Consolidate "FFI" and "FFI tips"

Open soupi opened this issue 8 years ago • 7 comments

It have been asked a few times on IRC:

  • "How do I return an Either String Int from JS?"
  • "How do I return MyCustomDatatype from JS?"

Two solutions that were brought up were to:

  • send the possible data constructors to be return (example, Left, Right, MyCustomDatatypeConstructor`, etc.),
  • send a function of type String :: Maybe MyCustomDatatype that will get a string version of that constructor and will decide which value to return based on that.

It'd be great if that'd be documented in the FFI guide. :)

soupi avatar Mar 23 '17 21:03 soupi

What, like this? :smile:

garyb avatar Mar 23 '17 21:03 garyb

Agreed it should be more prominent / perhaps expanded though.

garyb avatar Mar 23 '17 21:03 garyb

Ah, sorry! I skimmed the document a few times and concluded that part wasn't documented but here it is...

soupi avatar Mar 23 '17 21:03 soupi

It's under "FFI Tips" rather than just "FFI" in the guides, we should probably consolidate them :)

garyb avatar Mar 23 '17 21:03 garyb

Oh nice! I didn't know that was documented. We need to improve the organization of this repo.

chexxor avatar Mar 23 '17 21:03 chexxor

oh, missed it again. Yeah it would definitely help to merge the two guides.

soupi avatar Mar 23 '17 21:03 soupi

There's also an FFI page under "language". I think we should try to put it all under the language one.

hdgarrood avatar Jul 08 '17 13:07 hdgarrood