on master help sign in
convertible-text and failure
2e327beMichael Snoyman
Text/Libyaml.hs+20−14
@@ -23,13 +23,14 @@ import Foreign.Ptr
23import Foreign.ForeignPtr
23import Foreign.ForeignPtr
24import Foreign.Marshal.Alloc
24import Foreign.Marshal.Alloc
25
25
26−import Control.Monad.Failure
26+import Control.Failure
27import Data.Typeable (Typeable)
27import Data.Typeable (Typeable)
28import Control.Exception (Exception)
28import Control.Exception (Exception)
29
29
30−import Data.Convertible
30+import Data.Convertible.Text
31import Data.Text.Lazy (Text)
31import Data.Text.Lazy (Text)
32import Data.Object.Text ()
32import Data.Object.Text ()
33+import Control.Applicative
33
34
34data ParserStruct
35data ParserStruct
35type Parser = Ptr ParserStruct
36type Parser = Ptr ParserStruct
@@ -181,11 +182,16 @@ getEvent er = do
181 YamlMappingEndEvent -> return EventMappingEnd
182 YamlMappingEndEvent -> return EventMappingEnd
182
183
183data YAttempt v = YSuccess v | YFailure YamlException
184data YAttempt v = YSuccess v | YFailure YamlException
185+instance Functor YAttempt where
186+ fmap = liftM
187+instance Applicative YAttempt where
188+ pure = return
189+ (<*>) = ap
184instance Monad YAttempt where
190instance Monad YAttempt where
185 return = YSuccess
191 return = YSuccess
186 YSuccess v >>= f = f v
192 YSuccess v >>= f = f v
187 YFailure e >>= _ = YFailure e
193 YFailure e >>= _ = YFailure e
188−instance MonadFailure YamlException YAttempt where
194+instance Failure YamlException YAttempt where
189 failure = YFailure
195 failure = YFailure
190
196
191parserParse :: MonadFailure YamlException m
197parserParse :: MonadFailure YamlException m
@@ -291,10 +297,10 @@ foreign import ccall unsafe "yaml_scalar_event_initialize"
291 -> Ptr CUChar -- anchor
297 -> Ptr CUChar -- anchor
292 -> Ptr CUChar -- tag
298 -> Ptr CUChar -- tag
293 -> Ptr CUChar -- value
299 -> Ptr CUChar -- value
294− -> CInt
300+ -> CInt -- length
295− -> CInt
301+ -> CInt -- plain_implicit
296− -> CInt
302+ -> CInt -- quoted_implicit
297− -> CInt
303+ -> CInt -- style
298 -> IO CInt
304 -> IO CInt
299
305
300foreign import ccall unsafe "simple_document_start"
306foreign import ccall unsafe "simple_document_start"
@@ -350,13 +356,13 @@ toEventRaw e f = withEventRaw $ \er -> do
350 else value'
356 else value'
351 c_yaml_scalar_event_initialize
357 c_yaml_scalar_event_initialize
352 er
358 er
353− nullPtr
359+ nullPtr -- anchor
354− nullPtr
360+ nullPtr -- tag
355− value''
361+ value'' -- value
356− len'
362+ len' -- length
357− 0
363+ 0 -- plain_implicit
358− 1
364+ 1 -- quoted_implicit
359− 0 -- YAML_ANY_SCALAR_STYLE
365+ 0 -- YAML_ANY_SCALAR_STYLE
360 EventSequenceStart ->
366 EventSequenceStart ->
361 c_yaml_sequence_start_event_initialize
367 c_yaml_sequence_start_event_initialize
362 er
368 er
Text/Yaml.hs+1−1
@@ -50,7 +50,7 @@ import System.IO.Unsafe
50import Control.Arrow (first)
50import Control.Arrow (first)
51import Control.Monad (liftM, join)
51import Control.Monad (liftM, join)
52import Control.Monad.Trans
52import Control.Monad.Trans
53−import Data.Convertible
53+import Data.Convertible.Text
54import Data.Attempt
54import Data.Attempt
55
55
56import Data.Text.Lazy (Text)
56import Data.Text.Lazy (Text)
c/helper.c+1−1
@@ -56,7 +56,7 @@ unsigned char const * get_parser_error_context(yaml_parser_t *p)
56 return p->context;
56 return p->context;
57}
57}
58
58
59−unsigned int get_parser_error_offset(yaml_parser_t *p)
59+unsigned int get_parser_error_offset(yaml_parser_t *p)
60{
60{
61 return p->offset;
61 return p->offset;
62}
62}
yaml.cabal+9−10
@@ -25,16 +25,15 @@ library
25 else
25 else
26 Buildable: True
26 Buildable: True
27 build-depends: base >= 4 && < 5,
27 build-depends: base >= 4 && < 5,
28− data-object == 0.2.0,
28+ data-object >= 0.2.0 && < 0.3,
29− bytestring >= 0.9.1.4 && < 1,
29+ bytestring >= 0.9.1.4 && < 0.10,
30− haskell98,
31− time,
30+ time >= 1.1.4 && < 1.2,
32− safe-failure,
31+ safe-failure >= 0.4 && < 0.5,
33− transformers >= 0.1.4.0,
32+ transformers >= 0.1.4.0 && < 0.2,
34− control-monad-failure >= 0.4,
33+ failure >= 0.0.0 && < 0.1,
35− text >= 0.5,
34+ text >= 0.5 && < 0.6,
36− convertible >= 1.2.0,
35+ convertible-text >= 0.0.0 && < 0.1,
37− attempt >= 0.0.2
36+ attempt >= 0.2.0 && < 0.3
38 exposed-modules: Text.Yaml
37 exposed-modules: Text.Yaml
39 other-modules: Text.Libyaml
38 other-modules: Text.Libyaml
40 ghc-options: -Wall
39 ghc-options: -Wall