@@ -0,0 +1,24 @@
1+module Providers
2+
3+%dynamic "./nativetypes.so"
4+
5+sizeOfSizeT : IO Int
6+sizeOfSizeT = foreign FFI_C "sizeof_size_t" (IO Int)
7+
8+data NativeTypeSize = OneByte | TwoBytes | FourBytes | EightBytes
9+
10+instance Show NativeTypeSize where
11+ show OneByte = "1 byte"
12+ show TwoBytes = "2 bytes"
13+ show FourBytes = "4 bytes"
14+ show EightBytes = "8 bytes"
15+
16+bytesToType : Int -> Provider NativeTypeSize
17+bytesToType 1 = Provide OneByte
18+bytesToType 2 = Provide TwoBytes
19+bytesToType 4 = Provide FourBytes
20+bytesToType 8 = Provide EightBytes
21+bytesToType _ = Error "Unsupported size"
22+
23+getSizeOfSizeT : IO (Provider NativeTypeSize)
24+getSizeOfSizeT = map bytesToType sizeOfSizeT