packages feed

hoodle-parser 0.3.0 → 0.4

raw patch · 2 files changed

+45/−7 lines, 2 filesdep +directorydep ~hoodle-typesPVP ok

version bump matches the API change (PVP)

Dependencies added: directory

Dependency ranges changed: hoodle-types

API changes (from Hackage documentation)

- Text.Hoodle.Parse.Attoparsec: xstrk_color :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec: xstrk_tool :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec: xstrk_width :: XmlStroke -> StrokeWidth
- Text.Hoodle.Parse.Attoparsec: xstrk_xydata :: XmlStroke -> [Pair Double Double]
- Text.Hoodle.Parse.Attoparsec.V0_1_1: xstrk_color :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec.V0_1_1: xstrk_tool :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec.V0_1_1: xstrk_width :: XmlStroke -> StrokeWidth
- Text.Hoodle.Parse.Attoparsec.V0_1_1: xstrk_xydata :: XmlStroke -> [Pair Double Double]
- Text.Hoodle.Parse.Attoparsec.V0_2_2: xstrk_color :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec.V0_2_2: xstrk_tool :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec.V0_2_2: xstrk_width :: XmlStroke -> StrokeWidth
- Text.Hoodle.Parse.Attoparsec.V0_2_2: xstrk_xydata :: XmlStroke -> [Pair Double Double]
- Text.Hoodle.Parse.Attoparsec.V0_3: xstrk_color :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec.V0_3: xstrk_tool :: XmlStroke -> ByteString
- Text.Hoodle.Parse.Attoparsec.V0_3: xstrk_width :: XmlStroke -> StrokeWidth
- Text.Hoodle.Parse.Attoparsec.V0_3: xstrk_xydata :: XmlStroke -> [Pair Double Double]
+ Text.Hoodle.Parse.Attoparsec: [xstrk_color] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec: [xstrk_tool] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec: [xstrk_width] :: XmlStroke -> StrokeWidth
+ Text.Hoodle.Parse.Attoparsec: [xstrk_xydata] :: XmlStroke -> [Pair Double Double]
+ Text.Hoodle.Parse.Attoparsec.V0_1_1: [xstrk_color] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec.V0_1_1: [xstrk_tool] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec.V0_1_1: [xstrk_width] :: XmlStroke -> StrokeWidth
+ Text.Hoodle.Parse.Attoparsec.V0_1_1: [xstrk_xydata] :: XmlStroke -> [Pair Double Double]
+ Text.Hoodle.Parse.Attoparsec.V0_2_2: [xstrk_color] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec.V0_2_2: [xstrk_tool] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec.V0_2_2: [xstrk_width] :: XmlStroke -> StrokeWidth
+ Text.Hoodle.Parse.Attoparsec.V0_2_2: [xstrk_xydata] :: XmlStroke -> [Pair Double Double]
+ Text.Hoodle.Parse.Attoparsec.V0_3: [xstrk_color] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec.V0_3: [xstrk_tool] :: XmlStroke -> ByteString
+ Text.Hoodle.Parse.Attoparsec.V0_3: [xstrk_width] :: XmlStroke -> StrokeWidth
+ Text.Hoodle.Parse.Attoparsec.V0_3: [xstrk_xydata] :: XmlStroke -> [Pair Double Double]
+ Text.Hoodle.Parse.Util: withHoodle :: (MonadIO m, Functor m) => FilePath -> (Hoodle -> m a) -> m (Maybe a)

Files

hoodle-parser.cabal view
@@ -1,5 +1,5 @@ Name:		hoodle-parser-Version:	0.3.0+Version:	0.4 Synopsis:       Hoodle file parser Description: 	Text parser for hoodle xml file Homepage:       http://ianwookim.org/hoodle@@ -20,17 +20,19 @@   ghc-options: 	-Wall -funbox-strict-fields -fno-warn-unused-do-bind   ghc-prof-options: -caf-all -auto-all   Build-Depends: base == 4.*, -                 mtl > 2, -                 transformers >= 0.3,                   attoparsec >= 0.10, +                 either >= 3.1,                  bytestring >= 0.9,                   containers >= 0.4, +                 directory, +                 hoodle-types >= 0.4, +                 lens >= 2.5, +                 mtl > 2,                   strict >= 0.3, -                 hoodle-types >= 0.3.0, -                 xournal-types >= 0.5.1,                  text >= 0.11,-                 lens >= 2.5, -                 either >= 3.1+                 transformers >= 0.3, +                 xournal-types >= 0.5.1+   Exposed-Modules:                     Text.Hoodle.Migrate.FromXournal                    Text.Hoodle.Migrate.V0_1_1_to_V0_2_2@@ -40,6 +42,7 @@                    Text.Hoodle.Parse.Attoparsec.V0_1_1                    Text.Hoodle.Parse.Attoparsec.V0_2_2                    Text.Hoodle.Parse.Attoparsec.V0_3+                   Text.Hoodle.Parse.Util                    Text.Hoodle.Parse.Zlib                    Text.Hoodlet.Parse.Attoparsec 
+ src/Text/Hoodle/Parse/Util.hs view
@@ -0,0 +1,35 @@+-----------------------------------------------------------------------------+-- |+-- Module      : Text.Hoodle.Parse.Util+-- Copyright   : (c) 2015 Ian-Woo Kim+--+-- License     : BSD3+-- Maintainer  : Ian-Woo Kim <ianwookim@gmail.com>+-- Stability   : experimental+-- Portability : GHC+--+-----------------------------------------------------------------------------++module Text.Hoodle.Parse.Util where++import           Control.Applicative+import           Control.Monad.IO.Class+import           Data.Attoparsec.ByteString.Char8+import qualified Data.ByteString.Char8 as B+import           System.Directory+--+import           Data.Hoodle.Simple+--+import qualified Text.Hoodle.Parse.Attoparsec as PA++-- |+withHoodle :: (MonadIO m, Functor m) => FilePath -> (Hoodle -> m a) -> m (Maybe a)+withHoodle fname act = do+    b <- liftIO $ doesFileExist fname+    if not b+      then return Nothing+      else do+        bstr <- liftIO $ B.readFile fname+        case parseOnly PA.hoodle bstr of+          Left _err -> return Nothing+          Right hdl -> Just <$> act hdl