I have the following code:
data APNSIdentifier = NoIdentifier | Identifier Word32 deriving (Show, Eq)
newtype APNSItem = Item Put
createNotificationIdentifierItem :: APNSIdentifier -> APNSItem <--- here
createNotificationIdentifierItem (Identifier identifier) = do
putWord8 3
putWord16be 4
putWord32be identifier
How can I "wrap" the Put
monad with an APNSItem
? Do I have to make APNSItem
an instance of the Monad
typeclass or is there a simpler solution?
or
after making
APNSItem
an instance ofMonad
(you can do this withGeneralizedNewtypeDeriving
, but you'll need to fixAPNSItem
to have a single type variable first)