-- | -- Module: Data.RTCM3.TH -- Copyright: Copyright (C) 2015 Swift Navigation, Inc. -- License: LGPL-3 -- Maintainer: Mark Fine -- Stability: experimental -- Portability: portable -- -- Templated generation of RTCM3 interfaces. module Data.RTCM3.TH where import BasicPrelude hiding ( length ) import Data.Binary import Data.ByteString import Data.ByteString.Lazy hiding ( length ) import Data.RTCM3.Types import Language.Haskell.TH -- | Derive ToRTCM3 typeclass, given an RTCM3 message number name and the -- name of the implemented type. deriveRTCM3 :: Name -> Q [Dec] deriveRTCM3 name = [d|instance ToRTCM3 $(conT name) where toRTCM3 msg = Msg len payload crc where payload = toStrict $ encode msg len = fromIntegral $ length payload crc = checkCrc len payload |]