-- | Generate a mapping.
mapping :: Identifier -> Original -> PP ()
mapping (Identifier identifier) (Original (name,loc)) = modify $ \ps ->
  ps { psMappings = m ps : psMappings ps
     }

  where m ps = Mapping { mapGenerated = Pos (fromIntegral (psLine ps))
                                            (fromIntegral (psColumn ps))
                       , mapOriginal = Just (Pos (fromIntegral line)
                                                 (fromIntegral col - 1))
                       , mapSourceFile = Just (T.unpack (fastStringToText file))
                       , mapName = Just (T.toStrict (printName name))
                       }
        line = srcLocLine loc
        col = srcLocCol loc
        file = srcLocFile loc

-- | Generate a mapping just for a location.
mapping :: Identifier -> Original -> PP ()
mapping (Identifier identifier) (Original (name,loc)) = modify $ \ps ->
  ps { psMappings = m ps : psMappings ps
     }

  where m ps = Mapping { mapGenerated = Pos (fromIntegral (psLine ps))
                                            (fromIntegral (psColumn ps))
                       , mapOriginal = Just (Pos (fromIntegral line)
                                                 (fromIntegral col - 1))
                       , mapSourceFile = Just (T.unpack (fastStringToText file))
                       , mapName = Just (T.toStrict (printName name))
                       }
        line = srcLocLine loc
        col = srcLocCol loc
        file = srcLocFile loc

-- | Generate a mapping just for a location.
mapping (Identifier identifier) (Original (name,loc)) = modify $ \ps ->
  ps { psMappings = m ps : psMappings ps
     }

  where m ps = Mapping { mapGenerated = Pos (fromIntegral (psLine ps))
                                            (fromIntegral (psColumn ps))
                       , mapOriginal = Just (Pos (fromIntegral line)
                                                 (fromIntegral col - 1))
                       , mapSourceFile = Just (T.unpack (fastStringToText file))
                       , mapName = Just (T.toStrict (printName name))
                       }
        line = srcLocLine loc
        col = srcLocCol loc
        file = srcLocFile loc

-- | Generate a mapping just for a location.