module Fay.Compiler.Prelude
( module Prelude.Compat
, module Control.Applicative
, module Control.Arrow
, module Control.Monad.Compat
, module Data.Char
, module Data.Data
, module Data.Either
, module Data.Function
, module Data.List.Compat
, module Data.Maybe
, module Data.Monoid
, module Data.Ord
, module Data.Traversable
, module Safe
, anyM
, io
, readAllFromProcess
) where
import Control.Applicative
import Control.Arrow (first, second, (&&&), (***), (+++), (|||))
import Control.Monad.Compat hiding (guard)
import Data.Char hiding (GeneralCategory (..))
import Data.Data (Data (..), Typeable)
import Data.Either
import Data.Function (on)
import Data.List.Compat
import Data.Maybe
import Data.Monoid (Monoid (..), (<>))
import Data.Ord
import Data.Traversable
import Prelude.Compat hiding (exp, mod)
import Safe
import Control.Monad.Except hiding (filterM)
import System.Exit
import System.Process
io :: MonadIO m => IO a -> m a
io = liftIO
anyM :: (Functor m, Applicative m, Monad m) => (a -> m Bool) -> [a] -> m Bool
anyM p l = return . not . null =<< filterM p l
readAllFromProcess :: FilePath -> [String] -> String -> IO (Either (String,String) (String,String))
readAllFromProcess program flags input = do
(code,out,err) <- readProcessWithExitCode program flags input
return $ case code of
ExitFailure 127 -> Left ("cannot find executable " ++ program, "")
ExitFailure _ -> Left (err, out)
ExitSuccess -> Right (err, out)