{-# LANGUAGE CPP #-}
#undef WINDOWS
#define POSIX
#define IS_WINDOWS False
#define FILEPATH_NAME PosixPath
#define OSSTRING_NAME PosixString
#define WORD_NAME PosixChar
#include "Common.hs"
pstr :: QuasiQuoter
pstr :: QuasiQuoter
pstr =
QuasiQuoter
{ quoteExp :: String -> Q Exp
quoteExp = \String
s -> do
PosixString
ps <- forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show) forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ TextEncoding -> String -> Either EncodingException PosixString
encodeWith (CodingFailureMode -> TextEncoding
mkUTF8 CodingFailureMode
ErrorOnCodingFailure) String
s
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ PosixString -> Bool
isValid PosixString
ps) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"filepath not valid: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show PosixString
ps)
forall t (m :: * -> *). (Lift t, Quote m) => t -> m Exp
lift PosixString
ps
, quotePat :: String -> Q Pat
quotePat = \String
_ ->
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"illegal QuasiQuote (allowed as expression only, used as a pattern)"
, quoteType :: String -> Q Type
quoteType = \String
_ ->
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"illegal QuasiQuote (allowed as expression only, used as a type)"
, quoteDec :: String -> Q [Dec]
quoteDec = \String
_ ->
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"illegal QuasiQuote (allowed as expression only, used as a declaration)"
}