module Sound.OSC.Packet.Class where
import Sound.OSC.Coding.Class
import Sound.OSC.Packet
class OSC o where
toPacket :: o -> Packet
fromPacket :: Packet -> Maybe o
instance OSC Message where
toPacket = Packet_Message
fromPacket = packet_to_message
instance OSC Bundle where
toPacket = Packet_Bundle
fromPacket = Just . packet_to_bundle
instance OSC Packet where
toPacket = id
fromPacket = Just
encodeOSC :: (Coding c,OSC o) => o -> c
encodeOSC = encodePacket . toPacket
decodeOSC :: (Coding c,OSC o) => c -> Maybe o
decodeOSC = fromPacket . decodePacket