How to translate Elixir types to Gleam FFI? #4689
-
I am trying to use an Elixir Redis client in Gleam. The spec for the start_link function is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
In Gleam you would make a custom type. You could either make a type which translates to the exact same thing, like this: type LinkResult {
Ok(Pid)
Ignore
Error(Dynamic)
} However this isn't great as it shadows the What I would probably do instead is write a short function in elixir, which calls the |
Beta Was this translation helpful? Give feedback.
In Gleam you would make a custom type. You could either make a type which translates to the exact same thing, like this:
However this isn't great as it shadows the
Ok
andError
constructors of theResult
type.What I would probably do instead is write a short function in elixir, which calls the
start_link
function, pattern matches on the result, and turns it into a Gleam type which you define that better suits your API. This is also good practise for when the return type doesn't map so neatly to a Gleam type