Purely functional languages such as Haskell support call functions in foreign languages through "external function interfaces . "
The question arises how to encode the types and behavior of a foreign language function into a purely functional language (for example, Haskell).
Two cases can be considered:
Pure functions
. : sin :: CDouble -> CDouble C.
. . / , .
, , . , , , .
let state0 = initState
(v, state1) <- foreignFunction state0
(u, state2) <- foreignFunction state1
return (v,u)
, ( ) state. .
, , .
, , API- Haskell. : mersenne-twister binding., MTGen , .