-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Happstack data manipulation libraries -- -- This package provides libraries for: -- --
-- $( deriveAll [''Show, ''Eq, ''Default] [d| -- data Foo a = Foo a -- data Bar = Baz | Quux -- |] ) --deriveAll :: [Name] -> Q [Dec] -> Q [Dec] -- | Derives instances for syb-with-class's Data class and -- Happstack.Data.Default's Default class. The list of names should be of -- the form [''Foo,''Bar,..] deriveNewData :: [Name] -> Q [Dec] -- | Derives instances for syb-with-class's Data class only. The list of -- names should be of the form [''Foo,''Bar,..] deriveNewDataNoDefault :: [Name] -> Q [Dec] module Happstack.Data.Proxy -- | Proxy is empty and is used as a transport of a phantom type data Proxy t[a6ab] Proxy :: Proxy t[a6ab] dataType[a6ac] :: DataType constr[a6ad] :: Constr -- | Creates the Proxy with a type matching the argument proxy :: t -> Proxy t -- | Returns bottom unProxy :: Proxy t -> t -- | Acts as id except for providing type restrictions asProxyType :: t -> Proxy t -> t instance [overlap ok] (Typeable t[a6ab]) => Data (Proxy t[a6ab]) instance [overlap ok] Read (Proxy t[a6ab]) instance [overlap ok] Show (Proxy t[a6ab]) instance [overlap ok] (Data ctx t[a6ab], Sat (ctx (Proxy t[a6ab]))) => Data ctx (Proxy t[a6ab]) instance [overlap ok] Typeable1 Proxy instance [overlap ok] (Default t[a6ab]) => Default (Proxy t[a6ab]) module Happstack.Data.Serialize class (Typeable a, Version a) => Serialize a getCopy :: (Serialize a) => Contained (Get a) putCopy :: (Serialize a) => a -> Contained Put -- | The Version type class is used to describe whether a type is -- fundamental or if it is meant to extend another type. For a user -- defined type that does not extend any others, one can use the default -- instance of Version, e.g. instance Version MyType to define -- it has having a version id of 0 and previous type. class Version a mode :: (Version a) => Mode a -- | Migrate instances are needed to allow upgrades of MACID state. It -- should be declared as instance Migrate Old New where migrate = -- transition_function class Migrate a b migrate :: (Migrate a b) => a -> b data Mode a -- | Data layout won't change. Used for types like Int and Char. Primitive :: Mode a Versioned :: (VersionId a) -> (Maybe (Previous a)) -> Mode a data Contained a -- | Lifts the provided value into Contained contain :: a -> Contained a -- | Creates a Mode that is a new version of the type carried by the -- provided proxy and with the provided version number. Note that since -- VersionId is an instance of Num that you may use int literals when -- calling extension, e.g. extension 1 (Proxy :: Proxy OldState) extension :: (Serialize b, Migrate b a) => VersionId a -> Proxy b -> Mode a -- | Equivalent of Data.Binary.get for instances of Serialize Takes into -- account versioning of types. safeGet :: (Serialize a) => Get a -- | Equivalent of Data.Binary.put for instances of Serialize. Takes into -- account versioning of types. safePut :: (Serialize a) => a -> Put -- | Pure version of safePut. Serializes to a ByteString serialize :: (Serialize a) => a -> ByteString -- | Pure version of safeGet. Parses a ByteString into the expected -- type and a remainder. deserialize :: (Serialize a) => ByteString -> (a, ByteString) -- | Version lookups collectVersions :: (Typeable a, Version a) => Proxy a -> [ByteString] -- | Uniform container for any serialized data. It contains a string rep of -- the type and the actual data serialized to a byte string. data Object -- | Serializes data and stores it along with its type name in an Object mkObject :: (Serialize a) => a -> Object -- | deserialize specialized to Objects deserializeObject :: ByteString -> (Object, ByteString) -- | Attempts to convert an Object back into its base type. If the -- conversion fails error will be called. parseObject :: (Serialize a) => Object -> a instance [overlap ok] Typeable Object instance [overlap ok] Show Object instance [overlap ok] Num (VersionId a) instance [overlap ok] Read (VersionId a) instance [overlap ok] Show (VersionId a) instance [overlap ok] Eq (VersionId a) instance [overlap ok] Serialize Object instance [overlap ok] Version Object instance [overlap ok] (Serialize a) => Serialize (IntMap a) instance [overlap ok] Version (IntMap a) instance [overlap ok] (Serialize a, Serialize b, Ord a) => Serialize (Map a b) instance [overlap ok] Version (Map a b) instance [overlap ok] (Serialize a, Ord a) => Serialize (Set a) instance [overlap ok] Version (Set a) instance [overlap ok] (Serialize a) => Serialize (Maybe a) instance [overlap ok] Version (Maybe a) instance [overlap ok] (Serialize a) => Serialize [a] instance [overlap ok] Version [a] instance [overlap ok] (Typeable a) => Serialize (Proxy a) instance [overlap ok] Version (Proxy a) instance [overlap ok] (Serialize a, Serialize b, Serialize c, Serialize d, Serialize e) => Serialize (a, b, c, d, e) instance [overlap ok] Version (a, b, c, d, e) instance [overlap ok] (Serialize a, Serialize b, Serialize c, Serialize d) => Serialize (a, b, c, d) instance [overlap ok] Version (a, b, c, d) instance [overlap ok] (Serialize a, Serialize b, Serialize c) => Serialize (a, b, c) instance [overlap ok] Version (a, b, c) instance [overlap ok] (Serialize a, Serialize b) => Serialize (a, b) instance [overlap ok] Version (a, b) instance [overlap ok] (Serialize a, Serialize b) => Serialize (Either a b) instance [overlap ok] Version (Either a b) instance [overlap ok] Serialize Bool instance [overlap ok] Version Bool instance [overlap ok] Serialize () instance [overlap ok] Version () instance [overlap ok] Serialize Int64 instance [overlap ok] Version Int64 instance [overlap ok] Serialize Int32 instance [overlap ok] Version Int32 instance [overlap ok] Serialize Int16 instance [overlap ok] Version Int16 instance [overlap ok] Serialize Int8 instance [overlap ok] Version Int8 instance [overlap ok] Serialize Ordering instance [overlap ok] Version Ordering instance [overlap ok] Serialize Word64 instance [overlap ok] Version Word64 instance [overlap ok] Serialize Word32 instance [overlap ok] Version Word32 instance [overlap ok] Serialize Word16 instance [overlap ok] Version Word16 instance [overlap ok] Serialize Word8 instance [overlap ok] Version Word8 instance [overlap ok] Serialize Char instance [overlap ok] Version Char instance [overlap ok] Serialize ByteString instance [overlap ok] Version ByteString instance [overlap ok] Serialize ByteString instance [overlap ok] Version ByteString instance [overlap ok] Serialize Double instance [overlap ok] Version Double instance [overlap ok] Serialize Float instance [overlap ok] Version Float instance [overlap ok] Serialize Integer instance [overlap ok] Version Integer instance [overlap ok] Serialize Int instance [overlap ok] Version Int instance [overlap ok] Binary (VersionId a) module Happstack.Data.SerializeTH -- | Derives an instance of Serialize for the provided type Should work in -- most cases if the type is already and instance of Version. Ex: -- $(deriveSerialize ''Foo) deriveSerialize :: Name -> Q [Dec] -- | Derives Serialize for a list of types deriveSerializeFor :: [Name] -> Q [Dec] module Happstack.Data.Xml.HaXml isAttr :: Element -> Bool -- | Lifts toHaXml to act on lists of Elements toHaXmls :: [Element] -> [Content] -- | Converts the Element to HaXml Element if the Element is of the form -- Elem _ _ toHaXmlEl :: Element -> Element -- | Conversion function between the Happstack Element and HaXml Content -- types toHaXml :: Element -> Content -- | Converts an Element that is an Attr into a HaXml Attribute. Will throw -- an error if provided the wrong constructor. toAttribute :: Element -> Attribute -- | Lifts fromHaXml to operate on lists fromHaXmls :: [Content] -> [Element] -- | Converts a HaXml Content to an Element fromHaXml :: Content -> Element -- | Lifts fromAttribute to act on lists fromAttributes :: [Attribute] -> [Element] -- | Will convert a HaXml attribute that is of the form [Left _] to a -- Happstack Element. Otherwise, will throw an error. fromAttribute :: Attribute -> Element module Happstack.Data.Xml -- | Element recursively represents XML data. Elem n elems -> XML -- element with name n and described by elems. Note that elems contains -- sub-elements as well as the attributes or literal data of the element. -- CData d -> Literal string data Attr key val -> Key/Value pair of -- the element attribute. data Element Elem :: String -> [Element] -> Element CData :: String -> Element Attr :: String -> String -> Element dataType[aekv] :: DataType constr[aeky] :: Constr constr[aekx] :: Constr constr[aekw] :: Constr -- | insEl a b will convert a to xml and insert it into the xml of b if b -- results in an Elem constructor. insEl :: (Data XmlD a, Default a, Data NormalizeD a, Data XmlD b, Default b, Data NormalizeD b) => a -> b -> Element -- | Wrapper around the Xml class method readXml. The Rigidity will -- determine the behavior in the case of a failed parsing: Rigid will -- return Nothing and Flexible will return Identity (defaultValue) fromXml :: (Monad m, Xml a) => Rigidity m -> [Element] -> m a data Other b Other :: a -> Other b NoOther :: Other b -- | Identical to toXml from Xml class except that it will remove -- attributes named haskellType or haskellTypeVersion toPublicXml :: (Xml a) => a -> [Element] -- | Rigidity is used to designate the result of a failed Xml parsing. data Rigidity m Rigid :: Rigidity Maybe Flexible :: Rigidity Identity class (Data XmlD a, Default a, Normalize a) => Xml a toXml :: (Xml a) => a -> [Element] readXml :: (Xml a, Monad m) => Rigidity m -> [Element] -> Maybe ([Element], a) readXml' :: (Xml a, Monad m) => Rigidity m -> [Element] -> Maybe ([Element], a) normalizeXml :: (Xml a) => a -> [Element] -> [Element] version :: (Xml a) => a -> Maybe String otherVersion :: (Xml a) => a -> Other a typ :: (Xml a) => a -> String data XmlD a XmlD :: (a -> [Element]) -> (forall m. (Monad m) => Rigidity m -> ReadM m a) -> (forall m. (Monad m) => Rigidity m -> ReadM Maybe a) -> XmlD a toXmlD :: XmlD a -> a -> [Element] readMXmlD :: XmlD a -> forall m. (Monad m) => Rigidity m -> ReadM m a readMXmlNoRootDefaultD :: XmlD a -> forall m. (Monad m) => Rigidity m -> ReadM Maybe a -- | Used as a type witness for usage with syb-with-class Data class. xmlProxy :: Proxy XmlD -- | Applies function to only first element of the list. Safe on empty -- lists. first :: (a -> a) -> [a] -> [a] -- | Converts the argument to an Xml element with the constructor name as -- the root of the Elem and the additional attributes corresponding to -- haskellType and haskellTypeVersion added defaultToXml :: (Xml t) => t -> [Element] -- | Generically traverses an instance of Xml and converts it into a list -- of elements transparentToXml :: (Xml t) => t -> [Element] -- | Attempts to parse the set of elements and return the first constructor -- it can successfully parse of the inferred type. transparentReadXml :: (Monad m, Xml t) => Rigidity m -> [Element] -> Maybe ([Element], t) -- | Create an Xml instance using transparentToXml and transparentReadXml transparentXml :: Name -> Q [Dec] defaultReadXml :: (Monad m, Xml t) => Rigidity m -> [Element] -> Maybe ([Element], t) defaultReadXml' :: (Monad m, Xml t) => Rigidity m -> [Element] -> Maybe ([Element], t) readXmlWith :: (Xml t) => (Rigidity m -> Element -> Maybe t) -> Rigidity m -> [Element] -> Maybe ([Element], t) readVersionedElement :: (Monad m, Xml t) => Rigidity m -> Element -> Maybe t -- | Matches the provided string to the key of an attribute. Returns False -- if any other Element constructor is given. isTheAttr :: String -> Element -> Bool -- | Fetch the value of the given attribute if present, if not present will -- return Nothing getAttr :: String -> [Element] -> Maybe (String, [Element]) -- | Attribute used for Xml class version information versionAttr :: String -- | Attribute used for recording the actual Haskell type in the xml -- serialization typeAttr :: String readElement :: (Monad m, Xml t) => Rigidity m -> Element -> Maybe t -- | aConstrFromElements will return the results of the first constructor -- that parses correctly. aConstrFromElements :: (Monad m, Xml t) => Rigidity m -> [Constr] -> [Element] -> Maybe ([Element], t) -- | Like constrFromElements but does not allow defaulting in case of a -- parse error. constrFromElementsNoRootDefault :: (Monad m, Xml t) => Rigidity m -> Constr -> [Element] -> Maybe ([Element], t) -- | Attempts to parse the given elements to build the particular type -- given by the constructor argument. constrFromElements :: (Monad m, Xml t) => Rigidity m -> Constr -> [Element] -> m ([Element], t) type ReadM m = StateT ReadState m data ReadState ReadState :: [Element] -> ReadState xmls :: ReadState -> [Element] -- | Returns the elements currently in the state getXmls :: (Monad m) => ReadM m [Element] -- | Sets the state of the xml parsing to the given value putXmls :: (Monad m) => [Element] -> ReadM m () -- | Attempts to parse the current set of elements. If it fails the -- behavior is dependent on the Rigidity. If it is Rigid, then it will -- return Nothing but if it is Flexible it will return the defaultValue. -- If the parsing succeeds, it will return the value and store the -- remaining XML elements in the parser state. readMXml :: (Monad m, Xml a) => Rigidity m -> ReadM m a -- | Identical to readMXml except that in the case of a failed parsing it -- will not use defaultValue. readMXmlNoRootDefault :: (Monad m, Xml a) => Rigidity m -> ReadM Maybe a xmlAttr :: Name -> Q [Dec] -- | xmlShowCData lifted to act on lists xmlShowCDatas :: [Name] -> Q [Dec] -- | automatically creates an Xml definition for a type that is an instance -- of Show and Read. This will result in an instance that converts the -- type to and from CData. xmlShowCData :: Name -> Q [Dec] -- | xmlCDataLists lifted to act on lists xmlCDataLists :: [Name] -> Q [Dec] -- | Creates an instance similar to xmlShowCData except for lists of the -- provided type xmlCDataList :: Name -> Q [Dec] -- | Replaces commas in the string with single spaces noCommas :: String -> String -- | Throws an error when called typeNotValue :: (Xml a) => a -> a data K K :: String -> K data W W :: [K] -> W dataType[avPN] :: DataType constr[avPO] :: Constr dataType[avPD] :: DataType constr[avPE] :: Constr class ToString a toString :: (ToString a) => a -> String class FromString a fromString :: (FromString a, Monad m) => Rigidity m -> String -> m a module Happstack.Data.Pairs -- | Converts lists of string pairs into a list of Elements. The basic -- structure is pairsToXml [(foo,bar)] = [Elem foo -- [CData bar]] pairsToXml [(foo/bar,baz)] = [Elem -- foo [Elem bar [CData baz]]] pairsToXml :: Pairs -> [Element] -- | Converts a list of Elements to a list of String pairs. xmlToPairs -- [CData _] = error xmlToPairs [Elem foo [CData bar]] = -- [(foo,bar)] xmlToPairs [Elem foo [Elem bar -- [CData baz]]] = [(foo/bar,baz)] xmlToPairs . -- pairsToXml = id xmlToPairs :: [Element] -> Pairs -- | Creates the Xml structure corresponding to the specification of an -- HTML form. The provided pairs should be the spec of the inputs to the -- form. pairsToHTMLForm :: String -> String -> String -> Pairs -> [Element] -- | Equivalent to pairsToHTMLForm but first converts the Xml instance to -- list of pairs. xmlToHTMLForm :: (Xml a, Show a, Data a, Eq a) => String -> String -> String -> a -> [Element] toPairsX :: (Xml a, Show a, Data a, Eq a) => a -> Pairs -- | Equivalent to pairsToHTMLForm but first converts the Xml instance to -- list of pairs. An alias for xmlToHTMLForm currently. toHTMLForm :: (Xml a, Show a, Data a, Eq a) => String -> String -> String -> a -> [Element] type Pairs = [(String, String)] class (Xml x, Show x, Data x) => AsPairs x toPairs :: (AsPairs x) => x -> Pairs fromPairs :: (AsPairs x) => Pairs -> Maybe x instance [overlap ok] Data Pass instance [overlap ok] Show Pass instance [overlap ok] Eq Pass instance [overlap ok] Data User instance [overlap ok] Show User instance [overlap ok] Eq User instance [overlap ok] Data UserInfo instance [overlap ok] Show UserInfo instance [overlap ok] Eq UserInfo instance [overlap ok] (Data ctx String, Sat (ctx Pass), Sat (ctx String)) => Data ctx Pass instance [overlap ok] Typeable Pass instance [overlap ok] (Data ctx String, Sat (ctx User), Sat (ctx String)) => Data ctx User instance [overlap ok] Typeable User instance [overlap ok] (Data ctx User, Data ctx Pass, Sat (ctx UserInfo), Sat (ctx User), Sat (ctx Pass)) => Data ctx UserInfo instance [overlap ok] Typeable UserInfo instance [overlap ok] Default Pass instance [overlap ok] Default User instance [overlap ok] Default UserInfo instance [overlap ok] (Xml a, Show a, Data a, Eq a) => AsPairs a module Happstack.Data