Skip to content

Commit

Permalink
Support pure foreign functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edsko committed Apr 19, 2024
1 parent f70b040 commit 0dd1df3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/Test/TraceForeignCalls/UsePlugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ import Foreign.C
foreign import capi "test_cbits.h answer" c_answerIO :: IO CInt
foreign import capi "test_cbits.h slow_add" c_slowAddIO :: CLong -> CLong -> IO CLong

foreign import capi "test_cbits.h answer" c_answerPure :: CInt
foreign import capi "test_cbits.h slow_add" c_slowAddPure :: CLong -> CLong -> CLong

answerIO :: IO Int
answerIO = fromIntegral <$> c_answerIO

slowAddIO :: Int -> Int -> IO Int
slowAddIO a b = fromIntegral <$> c_slowAddIO (fromIntegral a) (fromIntegral b)

answerPure :: Int
answerPure = fromIntegral $ c_answerPure

slowAddPure :: Int -> Int -> Int
slowAddPure a b = fromIntegral $ c_slowAddPure (fromIntegral a) (fromIntegral b)

0 comments on commit 0dd1df3

Please sign in to comment.