5 module Rakka.Attachment
10 import Control.Arrow.ArrowList
11 import Control.Arrow.ListArrow
12 import Control.Arrow.Unicode
13 import System.IO.Unsafe
14 import Text.XML.HXT.Arrow.ReadDocument
15 import Text.XML.HXT.Arrow.WriteDocument
16 import Text.XML.HXT.Arrow.XmlArrow
17 import Text.XML.HXT.Arrow.XmlState
18 import Text.XML.HXT.DOM.TypeDefs
20 class Attachment τ where
21 serializeToXmlTree ∷ (ArrowChoice (⇝), ArrowXml (⇝)) ⇒ τ ⇝ XmlTree
22 deserializeFromXmlTree ∷ (ArrowChoice (⇝), ArrowXml (⇝)) ⇒ XmlTree ⇝ τ
24 -- FIXME: String? Am I okay with that?
25 serializeToString ∷ τ → String
26 serializeToString attachment
27 = do [xmlStr] ← runLA ( constA attachment
31 writeDocumentToString [ withIndent yes ]
35 deserializeFromString ∷ String → τ
36 deserializeFromString source
38 do [ret] ← runX ( setErrorMsgHandler False fail
40 readString [ withValidate no
41 , withCheckNamespaces yes
45 deserializeFromXmlTree