module Main (main) where
import Control.Applicative
import Control.Monad
-import qualified Data.Ascii as A
+import Data.Ascii (Ascii)
+import Data.Attempt
import Data.Char
+import Data.Convertible.Base
+import Data.Convertible.Utils
import Data.Maybe
import Language.Haskell.TH.PprLib
import Language.Haskell.TH.Syntax
= case mimeTypeOpts of
[] → Nothing
OptMIMEType ty:[]
- → case A.fromChars ty of
- Just a → Just $ parseMIMEType a
- Nothing → error "MIME types must not contain any non-ASCII letters."
+ → case convertAttemptVia ((⊥) ∷ Ascii) ty of
+ Success a → Just a
+ Failure e → error (show e)
_ → error "too many --mime-type options."
where
mimeTypeOpts ∷ [CmdOpt]
strToETag ∷ String → ETag
strToETag str
- = case A.fromChars str of
- Just a → strongETag a
- Nothing → error "ETag must not contain any non-ASCII letters."
+ = case ca str of
+ Success a → strongETag a
+ Failure e → error (show e)
openOutput ∷ [CmdOpt] → IO Handle
openOutput opts
= do i ← openInput srcFile (getMIMEType opts) (getETag opts)
o ← openOutput opts
doc ← pprInput i modName symName
- hPutStrLn o $ show $ to_HPJ_Doc doc
+ hPutStrLn o ∘ show $ to_HPJ_Doc doc
hClose o
where
modName ∷ ModName