{-# LANGUAGE ViewPatterns #-}

module RnHsDoc ( rnHsDoc, rnLHsDoc, rnMbLHsDoc ) where

import GhcPrelude

import TcRnTypes
import GHC.Hs
import SrcLoc


rnMbLHsDoc :: Maybe LHsDocString -> RnM (Maybe LHsDocString)
rnMbLHsDoc :: Maybe LHsDocString -> RnM (Maybe LHsDocString)
rnMbLHsDoc Maybe LHsDocString
mb_doc = case Maybe LHsDocString
mb_doc of
  Just LHsDocString
doc -> do
    LHsDocString
doc' <- LHsDocString -> RnM LHsDocString
rnLHsDoc LHsDocString
doc
    Maybe LHsDocString -> RnM (Maybe LHsDocString)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsDocString -> Maybe LHsDocString
forall a. a -> Maybe a
Just LHsDocString
doc')
  Maybe LHsDocString
Nothing -> Maybe LHsDocString -> RnM (Maybe LHsDocString)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe LHsDocString
forall a. Maybe a
Nothing

rnLHsDoc :: LHsDocString -> RnM LHsDocString
rnLHsDoc :: LHsDocString -> RnM LHsDocString
rnLHsDoc (LHsDocString -> Located (SrcSpanLess LHsDocString)
forall a. HasSrcSpan a => a -> Located (SrcSpanLess a)
dL->L SrcSpan
pos SrcSpanLess LHsDocString
doc) = do
  HsDocString
doc' <- HsDocString -> RnM HsDocString
rnHsDoc HsDocString
SrcSpanLess LHsDocString
doc
  LHsDocString -> RnM LHsDocString
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> SrcSpanLess LHsDocString -> LHsDocString
forall a. HasSrcSpan a => SrcSpan -> SrcSpanLess a -> a
cL SrcSpan
pos HsDocString
SrcSpanLess LHsDocString
doc')

rnHsDoc :: HsDocString -> RnM HsDocString
rnHsDoc :: HsDocString -> RnM HsDocString
rnHsDoc = HsDocString -> RnM HsDocString
forall (f :: * -> *) a. Applicative f => a -> f a
pure