Skip to content

Commit

Permalink
add pointer instances
Browse files Browse the repository at this point in the history
  • Loading branch information
mauke committed Oct 21, 2024
1 parent 82afda8 commit 4c07aa2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Data/Default/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ import Data.Ratio
import Data.Complex
import Data.Fixed
import Foreign.C.Types
#if MIN_VERSION_base(4, 18, 0)
import Foreign.C.ConstPtr
#endif
import Foreign.Ptr
import Data.Proxy
import Data.Functor.Identity
import Control.Applicative (Const(..))
Expand Down Expand Up @@ -141,6 +145,14 @@ instance Default CSUSeconds where def = 0
instance Default CFloat where def = 0
instance Default CDouble where def = 0

instance Default (Ptr a) where def = nullPtr
instance Default (FunPtr a) where def = nullFunPtr
instance Default IntPtr where def = ptrToIntPtr def
instance Default WordPtr where def = ptrToWordPtr def
#if MIN_VERSION_base(4, 18, 0)
instance Default (ConstPtr a) where def = ConstPtr def
#endif

instance Default (Maybe a) where def = Nothing
instance (Default a) => Default (Identity a) where def = Identity def
instance (Default a) => Default (Const a b) where def = Const def
Expand Down

0 comments on commit 4c07aa2

Please sign in to comment.