{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE ForeignFunctionInterface #-} import Data.Data (Data) import Foreign.C.Types import Foreign.Ptr import Foreign.Storable.ATS import GHC.Generics (Generic) import Test.Hspec foreign import ccall unsafe something :: Ptr (Option Product) data Option a = Some a | None deriving (Show, Eq, Generic, Functor, Data, ATSStorable) data Pair a b = Pair { _first :: a, _second :: b } deriving (Show, Eq, Generic, Data, ATSStorable) type Product = Pair CInt CInt somethingVal :: IO (Option Product) somethingVal = readPtr something main :: IO () main = hspec $ describe "readPtr" $ parallel $ it "should work on a combined sum/product type" $ somethingVal >>= (`shouldBe` (Some (Pair 1 6)))