aboutsummaryrefslogtreecommitdiff
path: root/plug/src/Montis/Foreign.hs
blob: fbbfb0845a50afc58812a2d419828d64e0722c30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Montis.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)