packages feed

tilia-0.2.0.0: corpora/vendored/cpp/expression/code-after-an-optional-prefix-under-an-operator-out'.hs

{-# LANGUAGE CPP #-}

-- An operator leading code that one branch puts a prefix in front of goes
-- to the end of the line before, and the code comes out once.
module Ide.Plugin.GHC (adjustWhere, fromString) where

adjustWhere :: AnnSortKey -> AnnSortKey
adjustWhere tcdDExt =
    tcdDExt <&>
#if !MIN_VERSION_ghc(9,9,0)
        map
#endif
        ( \(AddEpAnn ann l) ->
            if ann == AnnWhere
                then AddEpAnn AnnWhere d1
                else AddEpAnn ann l
        )

fromString :: ShakespeareSettings -> String -> Q Exp
fromString r str = do
    s <-
        qRunIO
            $ preFilter Nothing r $
#ifdef WINDOWS
            filter
                (/= '\r')
#endif
            str
    contentsToShakespeare r $ contentFromString r s