garnet/haskell/exe/Main.hs

22 lines
650 B
Haskell
Raw Normal View History

2026-02-17 14:57:34 +00:00
module Main (main) where
2026-02-19 11:11:23 +00:00
import Foreign
import Foreign.C
2026-02-19 11:11:23 +00:00
import GarnetRs
import GarnetRs.Safe
2026-02-19 11:11:23 +00:00
import HsBindgen.Runtime.Marshal
import HsBindgen.Runtime.PtrConst
2026-02-17 14:57:34 +00:00
main :: IO ()
main = do
withCString "Haskell" $ hello . unsafeFromPtr
2026-02-19 11:11:23 +00:00
alloca \ptr -> do
writeRaw ptr T{a = CBool 1, b = 42}
hello_struct (unsafeFromPtr ptr)
alloca \ptr -> do
writeRaw ptr (Shape (Shape_Tag 0) (set_shape_body_circle (Circle_Body 3.14)))
hello_shape (unsafeFromPtr ptr)
alloca \ptr -> do
writeRaw ptr (Shape (Shape_Tag 1) (set_shape_body_rectangle (Rectangle_Body 10.0 5.0)))
hello_shape (unsafeFromPtr ptr)