FFI Functions

FFI Functions

We have also provided some nice functions allowing you to “directly” use an Erlang library:

--if we want to use sin function from math module in Erlang
sin :: Float -> Float
sin = ffi1 :math :sin

-- foreign import ffi1 :: forall a b. Atom -> Atom -> a -> b

Where ffi1 is a function takes in two atoms to locate the function in the Erlang library, and the number 1 means this function needs argument. There are more in the lib.