I'd like to export a Haskell function that takes a function argument:
foreign export javascript "myFun" myFun :: (Int -> Int) -> Int
myFun :: (Int -> Int) -> Int
myFun f = f (f 0)
However, ahc-link complains that Int -> Int is not a valid parameter type for an FFI-exported function:
• Unacceptable argument type in foreign declaration:
‘Int -> Int’ cannot be marshalled in a foreign call
• When checking declaration:
foreign export javascript "myFun" myFun :: (Int -> Int) -> Int
The other possibility would be to pass the function as a JSVal, but then I don't know how to cast that into something that I can apply on Ints on the Haskell side.