{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} module Boilerplate.GhcParser (parseHaskell) where import Control.Monad.Trans.Except (runExceptT) import Data.Either (fromRight) import GHC.Paths (libdir) import HsInspect.Runner import HsInspect.Types (Comment(..), Type(..), types) parseHaskell :: FilePath -> IO ([Type], [Comment]) parseHaskell :: FilePath -> IO ([Type], [Comment]) parseHaskell FilePath file = do let fallback :: [FilePath] fallback = [FilePath "-B" forall a. Semigroup a => a -> a -> a <> FilePath libdir] [FilePath] flags <- forall b a. b -> Either a b -> b fromRight [FilePath] fallback forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a) runExceptT forall b c a. (b -> c) -> (a -> b) -> a -> c . Maybe FilePath -> ExceptT FilePath IO [FilePath] ghcflags_flags forall a b. (a -> b) -> a -> b $ forall a. a -> Maybe a Just FilePath file) forall a. [FilePath] -> Bool -> Ghc a -> IO a runGhcAndJamMasterShe [FilePath] flags Bool False forall a b. (a -> b) -> a -> b $ forall (m :: * -> *). GhcMonad m => FilePath -> m ([Type], [Comment]) types FilePath file