aboutsummaryrefslogtreecommitdiff
path: root/src/Wetterhorn/Foreign.hs
blob: 2d0a42c7b98f45bc43a94f7243cc7dce1afbad75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Wetterhorn.Foreign
  ( TypedIntPtr (..),
    toPtr,
    fromPtr,
  )
where

import Foreign (IntPtr, Ptr)
import qualified Foreign

toPtr :: TypedIntPtr a -> Ptr a
toPtr (TypedIntPtr ip) = Foreign.intPtrToPtr ip

fromPtr :: Ptr a -> TypedIntPtr a
fromPtr = TypedIntPtr . Foreign.ptrToIntPtr

newtype TypedIntPtr a = TypedIntPtr IntPtr
  deriving (Show, Read, Eq, Ord, Num)