on master help sign in
convertible-text and failure
commit2e327bec4e53103def5ad1d5756299a417e55d46 authorMichael Snoyman <michael@snoyman.com> dateSun 6 Dec 2009, 00:49 (17 years ago) parent4e92566
4 files changed+31−26
Text/Libyaml.hs+20−14 Text/Yaml.hs+1−1 c/helper.c+1−1 yaml.cabal+9−10
Text/Libyaml.hs+20−14
@@ -23,13 +23,14 @@ import Foreign.Ptr
2323import Foreign.ForeignPtr
2424import Foreign.Marshal.Alloc
2525
26−import Control.Monad.Failure
26+import Control.Failure
2727import Data.Typeable (Typeable)
2828import Control.Exception (Exception)
2929
30−import Data.Convertible
30+import Data.Convertible.Text
3131import Data.Text.Lazy (Text)
3232import Data.Object.Text ()
33+import Control.Applicative
3334
3435data ParserStruct
3536type Parser = Ptr ParserStruct
@@ -181,11 +182,16 @@ getEvent er = do
181182 YamlMappingEndEvent -> return EventMappingEnd
182183
183184data YAttempt v = YSuccess v | YFailure YamlException
185+instance Functor YAttempt where
186+ fmap = liftM
187+instance Applicative YAttempt where
188+ pure = return
189+ (<*>) = ap
184190instance Monad YAttempt where
185191 return = YSuccess
186192 YSuccess v >>= f = f v
187193 YFailure e >>= _ = YFailure e
188−instance MonadFailure YamlException YAttempt where
194+instance Failure YamlException YAttempt where
189195 failure = YFailure
190196
191197parserParse :: MonadFailure YamlException m
@@ -291,10 +297,10 @@ foreign import ccall unsafe "yaml_scalar_event_initialize"
291297 -> Ptr CUChar -- anchor
292298 -> Ptr CUChar -- tag
293299 -> Ptr CUChar -- value
294− -> CInt
295− -> CInt
296− -> CInt
297− -> CInt
300+ -> CInt -- length
301+ -> CInt -- plain_implicit
302+ -> CInt -- quoted_implicit
303+ -> CInt -- style
298304 -> IO CInt
299305
300306foreign import ccall unsafe "simple_document_start"
@@ -350,13 +356,13 @@ toEventRaw e f = withEventRaw $ \er -> do
350356 else value'
351357 c_yaml_scalar_event_initialize
352358 er
353− nullPtr
354− nullPtr
355− value''
356− len'
357− 0
358− 1
359− 0 -- YAML_ANY_SCALAR_STYLE
359+ nullPtr -- anchor
360+ nullPtr -- tag
361+ value'' -- value
362+ len' -- length
363+ 0 -- plain_implicit
364+ 1 -- quoted_implicit
365+ 0 -- YAML_ANY_SCALAR_STYLE
360366 EventSequenceStart ->
361367 c_yaml_sequence_start_event_initialize
362368 er
Text/Yaml.hs+1−1
@@ -50,7 +50,7 @@ import System.IO.Unsafe
5050import Control.Arrow (first)
5151import Control.Monad (liftM, join)
5252import Control.Monad.Trans
53−import Data.Convertible
53+import Data.Convertible.Text
5454import Data.Attempt
5555
5656import Data.Text.Lazy (Text)
c/helper.c+1−1
@@ -56,7 +56,7 @@ unsigned char const * get_parser_error_context(yaml_parser_t *p)
5656 return p->context;
5757}
5858
59−unsigned int get_parser_error_offset(yaml_parser_t *p)
59+unsigned int get_parser_error_offset(yaml_parser_t *p)
6060{
6161 return p->offset;
6262}
yaml.cabal+9−10
@@ -25,16 +25,15 @@ library
2525 else
2626 Buildable: True
2727 build-depends: base >= 4 && < 5,
28− data-object == 0.2.0,
29− bytestring >= 0.9.1.4 && < 1,
30− haskell98,
31− time,
32− safe-failure,
33− transformers >= 0.1.4.0,
34− control-monad-failure >= 0.4,
35− text >= 0.5,
36− convertible >= 1.2.0,
37− attempt >= 0.0.2
28+ data-object >= 0.2.0 && < 0.3,
29+ bytestring >= 0.9.1.4 && < 0.10,
30+ time >= 1.1.4 && < 1.2,
31+ safe-failure >= 0.4 && < 0.5,
32+ transformers >= 0.1.4.0 && < 0.2,
33+ failure >= 0.0.0 && < 0.1,
34+ text >= 0.5 && < 0.6,
35+ convertible-text >= 0.0.0 && < 0.1,
36+ attempt >= 0.2.0 && < 0.3
3837 exposed-modules: Text.Yaml
3938 other-modules: Text.Libyaml
4039 ghc-options: -Wall