How do you connect to a functionally pure language API?

I'm just curious to know how, in a purely functional language, you can connect to the API without introducing side effects?

+3
source share
2 answers

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 , .

+5

API , . , .

0

All Articles