diff --git a/exe/GarnetRs/Wrapped.hs b/exe/GarnetRs/Wrapped.hs index cb4d44c..a7633db 100644 --- a/exe/GarnetRs/Wrapped.hs +++ b/exe/GarnetRs/Wrapped.hs @@ -21,6 +21,7 @@ import Foreign.C import GarnetRs qualified as Raw import GarnetRs.Safe qualified as Raw import HsBindgen.Runtime.PtrConst +import System.IO.Unsafe data T = T { a :: Bool @@ -65,5 +66,5 @@ helloShape = Raw.hello_shape . convertShape add :: Int64 -> Int64 -> Int64 add = Raw.add -sumTree :: BTree Int64 -> IO Int64 -sumTree = flip withBTree Raw.sum_tree +sumTree :: BTree Int64 -> Int64 +sumTree = unsafePerformIO . flip withBTree Raw.sum_tree diff --git a/exe/Main.hs b/exe/Main.hs index 7e3bee8..e950324 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -10,4 +10,4 @@ main = do helloShape $ Circle 3.14 helloShape $ Rectangle 10.0 5.0 putStrLn $ "3 + 4 = " <> show (add 3 4) - putStrLn . ("Tree sum: " <>) . show =<< sumTree (Fork (Fork (Leaf 1) (Fork (Leaf 2) (Leaf 3))) (Leaf 4)) + putStrLn $ "Tree sum: " <> show (sumTree (Fork (Fork (Leaf 1) (Fork (Leaf 2) (Leaf 3))) (Leaf 4)))