X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=ImplantFile.hs;h=cbada793366c7b1d1265cdc0d2401f4602c1d300;hp=b6545a85df72082b0260f879a37e3bdb31c618dd;hb=HEAD;hpb=4e41b11200285142757434e9d67e17ed20fae455 diff --git a/ImplantFile.hs b/ImplantFile.hs index b6545a8..cbada79 100644 --- a/ImplantFile.hs +++ b/ImplantFile.hs @@ -4,13 +4,16 @@ 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 import Network.HTTP.Lucu.ETag -import Network.HTTP.Lucu.Implant.Input +import Network.HTTP.Lucu.Implant import Network.HTTP.Lucu.Implant.PrettyPrint import Network.HTTP.Lucu.MIMEType import Prelude.Unicode @@ -97,9 +100,9 @@ getMIMEType opts = 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] @@ -122,9 +125,9 @@ getETag opts 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 @@ -179,7 +182,7 @@ generateHaskellSource opts srcFile = 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