internetmarke 0.0.3 → 0.0.4
raw patch · 2 files changed
+35/−23 lines, 2 filesdep ~explicit-exceptiondep ~processdep ~transformers
Dependency ranges changed: explicit-exception, process, transformers
Files
- internetmarke.cabal +17/−6
- src/Main.hs +18/−17
internetmarke.cabal view
@@ -1,5 +1,5 @@ Name: internetmarke-Version: 0.0.3+Version: 0.0.4 License: GPL License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -33,8 +33,8 @@ It's also good if you have @wget@ installed for fetching the logo of the German Post. Stability: Experimental-Tested-With: GHC==6.8.2-Cabal-Version: >=1.2+Tested-With: GHC==6.8.2, GHC==7.8.4, GHC==8.4.4+Cabal-Version: >=1.10 Build-Type: Simple -- We ship an empty dummy file in order to let Cabal create the data directory.@@ -42,15 +42,24 @@ Data-files: data/Dummy +Source-Repository head+ type: darcs+ location: http://code.haskell.org/~thielema/internetmarke/++Source-Repository this+ tag: 0.0.4+ type: darcs+ location: http://code.haskell.org/~thielema/internetmarke/+ Flag splitBase description: Choose the new smaller, split-up base package. Executable internetmarke Build-Depends:- explicit-exception >=0.1 && <0.2,- transformers >=0.2 && <0.4,+ explicit-exception >=0.1 && <0.3,+ transformers >=0.2 && <0.7, utility-ht >=0.0.1 && <0.1,- process >=1.0 && <1.2,+ process >=1.0 && <1.7, parsec >=2.1 && <3.2, HPDF >=1.4 && <1.5 @@ -61,6 +70,8 @@ Build-Depends: base >=1.0 && <2 + Default-Language: Haskell98 GHC-Options: -Wall Hs-source-dirs: src Main-Is: Main.hs+ Other-Modules: Paths_internetmarke
src/Main.hs view
@@ -15,10 +15,10 @@ import Data.Char (isSpace, ) import Data.Maybe (mapMaybe, ) -import System.Cmd (rawSystem, )-import System.Process (runInteractiveProcess, waitForProcess, )+import System.Process (runInteractiveProcess, waitForProcess, rawSystem, ) import System.IO (withFile, hGetContents, hGetChar, IOMode(ReadMode), )-import System.IO.Error (ioeGetFileName, isDoesNotExistError, try, )+import System.IO.Error (ioeGetFileName, isDoesNotExistError, )+import Control.Exception (try, ) import Paths_internetmarke (getDataDir, ) import System.Console.GetOpt (getOpt, ArgOrder(..), OptDescr(..), ArgDescr(..), usageInfo, )@@ -29,6 +29,7 @@ import Control.Monad.Trans.State (StateT, evalStateT, gets, modify, ) import Control.Monad.Trans.Class (lift, ) import Control.Monad (liftM, liftM2, liftM3, when, )+import Control.Functor.HT (void, ) data Picture = Picture {@@ -44,7 +45,7 @@ makePicture name jpeg = do ref <- createPDFJpeg jpeg let (width, height) = jpegBounds jpeg- return $ Picture name width height ref+ return $ Picture name (fromIntegral width) (fromIntegral height) ref data Drawing = Drawing { drawPath :: FilePath,@@ -173,17 +174,17 @@ Parser.many1 $ do sprice <- parseSatisfyLine (isSuffixOf "EUR") sdate <- parseSatisfyLine (const True)- parseSatisfyLine null+ void $ parseSatisfyLine null return (sprice, sdate) textsB <- Parser.count (length textsA) $ do scode <- parseSatisfyLine (const True)- parseSatisfyLine null+ void $ parseSatisfyLine null return scode textsC <- Parser.count (length textsA) $ do sdomain <- parseSatisfyLine (const True)- parseSatisfyLine null+ void $ parseSatisfyLine null return sdomain return $ zipWith3 (\(sprice, sdate) scode sdomain ->@@ -209,46 +210,46 @@ parseFixedPoint :: Parser.CharParser st Double parseFixedPoint = do integer <- Parser.many1 Parser.digit- Parser.char '.'+ void $ Parser.char '.' fraction <- Parser.many1 Parser.digit return $ read $ integer ++ "." ++ fraction parsePoint :: Parser.CharParser st Point parsePoint = do x <- parseFixedPoint- Parser.char ','+ void $ Parser.char ',' y <- parseFixedPoint Parser.spaces return $ x:+(-y) parsePolygon :: Parser.CharParser st (Draw ()) parsePolygon =- do Parser.string "points=\""+ do void $ Parser.string "points=\"" (p:ps) <- Parser.many1 $ do p <- parsePoint return (2.562571*p + (86.77773:+(-644.0665)))- Parser.string "\""+ void $ Parser.string "\"" return $ beginPath p >> addPolygonToPath ps >> fillPath parsePath :: Parser.CharParser st (Draw ()) parsePath =- do Parser.string "d=\""+ do void $ Parser.string "d=\"" path <- Parser.many1 $ Parser.choice $- (do Parser.char 'M'+ (do void $ Parser.char 'M' Parser.spaces liftM beginPath parsePoint) :- (do Parser.char 'z'+ (do void $ Parser.char 'z' Parser.spaces return closePath) :- (do Parser.char 'L'+ (do void $ Parser.char 'L' Parser.spaces liftM addLineToPath parsePoint) :- (do Parser.char 'C'+ (do void $ Parser.char 'C' Parser.spaces liftM3 addBezierCubic parsePoint parsePoint parsePoint) : []- Parser.string "\""+ void $ Parser.string "\"" return $ sequence_ path >> fillPath makeLogo :: String -> Drawing