1 {-# LANGUAGE ForeignFunctionInterface #-}
10 foreign import ccall
"qpawn.c init"
13 foreign import ccall
"qpawn.c quit"
16 foreign import ccall
"qpawn.c clear"
19 foreign import ccall
"qpawn.c draw"
22 foreign import ccall
"qpawn.c pixel"
23 c_pixel
:: CInt
-> CInt
-> IO ()
25 foreign import ccall
"qpawn.c color"
26 c_color
:: CInt
-> CInt
-> CInt
-> IO ()
28 foreign import ccall
"qpawn.c sleep"
29 c_sleep
:: CInt
-> IO ()
31 foreign import ccall
"qpawn.c line"
32 c_line
:: CInt
-> CInt
-> CInt
-> CInt
-> IO ()
34 foreign import ccall
"qpawn.c rect"
35 c_rect
:: CInt
-> CInt
-> CInt
-> CInt
-> IO ()
38 ap2
:: (a
-> a
-> b
) -> [a
] -> b
40 ap2 _ _
= error "a list too small given to ap2"
42 ap3
:: (a
-> a
-> a
-> b
) -> [a
] -> b
43 ap3 f
(a
:b
:c
:_
) = f a b c
44 ap3 _ _
= error "a list too small given to ap3"
46 ap4
:: (a
-> a
-> a
-> a
-> b
) -> [a
] -> b
47 ap4 f
(a
:b
:c
:d
:_
) = f a b c d
48 ap4 _ _
= error "a list too small given to ap4"
50 cint
:: (Integral a
) => a
-> CInt
51 cint n
= (fromIntegral n
) :: CInt
53 cints
:: (Integral a
) => [a
] -> [CInt
]
56 color
:: [Int] -> IO ()
57 color
= ap3 c_color
. cints
59 pixel
:: [Int] -> IO ()
60 pixel
= ap2 c_pixel
. cints
62 line
:: [Int] -> IO ()
63 line
= ap4 c_line
. cints
65 rect
:: [Int] -> IO ()
66 rect
= ap4 c_rect
. cints
72 sleep
= c_sleep
. cint
84 line
[-255,-255, 255, 255]