[fptools/libraries/HaXml: changeset 2004-02-27 16:42:38 by malcolm malcolm**20040227164238 Change the API of Haskell2Xml to match the naming in Xml2Haskell. ] { hunk ./docs/Haskell2Xml.html 41 -To read and write Haskell data values as XML files, use the functions +To read and write Haskell data values as XML files, you +have a choice of function pairs: toXML/fromXML +convert between typed Haskell values and the generic internal +XML representation; showXml/readXml convert to/from +Strings; fWriteXml/fReadXml convert to/from named files; +hPutXml/hGetXml convert to/from file Handles. + hunk ./docs/Haskell2Xml.html 49 - Haskell2Xml.readXml :: XmlContent a => FilePath -> IO a - Haskell2Xml.writeXml :: XmlContent a => FilePath -> a -> IO () + toXml :: Haskell2Xml a => a -> Document + fromXml :: Haskell2Xml a => Document -> a + + readXml :: Haskell2Xml a => String -> Maybe a + showXml :: Haskell2Xml a => a -> String + + fReadXml :: Haskell2Xml a => FilePath -> IO a + fWriteXml :: Haskell2Xml a => FilePath -> a -> IO () + + hGetXml :: Haskell2Xml a => Handle -> IO a + hPutXml :: Haskell2Xml a => Handle -> a -> IO () hunk ./docs/Haskell2Xml.html 61 -not forgetting to resolve the overloading in one of the usual ways + +
+(These signatures are extremely similar to those in +Xml2Haskell - the only difference is +the class context, indicating how the types have been derived.) + +
+Do not forget to resolve the overloading in one of the usual ways
hunk ./docs/Xml2Haskell.html 50
-not forgetting to resolve the overloading in one of the usual ways
-(e.g. by implicit context at point of use, by explicit type signatures
-on values, use value as an argument to a function with an explicit
-signature, use `asTypeOf`, etc.)
+not forgetting to resolve the overloading in one of the usual
+ways (e.g. by implicit context at point of use, by explicit type
+signatures on values, use value as an argument to a function with
+an explicit signature, use `asTypeOf`, etc.) (Also, note
+the similarity between these signatures and those provided by the
+Haskell2Xml library.)
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 11
--- The functions 'readXml' and 'writeXml' do the conversion to and from
+-- The functions 'readXml' and 'showXml' convert to and from Strings.
+-- The functions 'fReadXml' and 'fWriteXml' do the conversion to and from
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 14
--- The functions 'hReadXml' and 'hWriteXml' do the conversion to and from
+-- The functions 'hGetXml' and 'hPutXml' do the conversion to and from
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 25
- -- ** IO functions
- , readXml, writeXml
- , hReadXml, hWriteXml
+ , readXml, showXml
+ -- ** IO conversion functions
+ , fReadXml, fWriteXml
+ , hGetXml, hPutXml
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 339
+
+-- | Convert an XML document encoded as a String, into a Haskell value.
+readXml :: Haskell2Xml a => String -> Maybe a
+readXml s = Just . fromXml . xmlParse "string input"
+-- | Convert a Haskell value to an XML document, encoded as a String.
+showXml :: Haskell2Xml a => a -> String
+showXml = render . PP.document . toXml
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 349
-readXml :: Haskell2Xml a => FilePath -> IO a
-readXml fp = do
+fReadXml :: Haskell2Xml a => FilePath -> IO a
+fReadXml fp = do
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 357
-writeXml :: Haskell2Xml a => FilePath -> a -> IO ()
-writeXml fp v = do
+fWriteXml :: Haskell2Xml a => FilePath -> a -> IO ()
+fWriteXml fp v = do
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 365
-hReadXml :: Haskell2Xml a => Handle -> IO a
-hReadXml f = do
+hGetXml :: Haskell2Xml a => Handle -> IO a
+hGetXml f = do
hunk ./src/Text/XML/HaXml/Haskell2Xml.hs 368
- return (fromXml (xmlParse "