-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Happstack data manipulation libraries -- -- This package provides libraries for: -- -- @package happstack-data @version 0.5.0.3 module Happstack.Data.GOps -- | gSet x y will traveral x and replace any instances -- of the type a in its structure with y. gSet :: (Data b, Typeable a) => a -> b -> b -- | gReplace f b will traverse x and will act on any -- instance of the type a in its structure with the function -- f. gReplace :: (Typeable a, Data b) => (a -> a) -> b -> b -- | gFind a will extract any elements of type b from -- a's structure in accordance with the MonadPlus instance, e.g. -- Maybe Foo will return the first Foo found while [Foo] will return the -- list of Foos found. gFind :: (MonadPlus m, Data a, Typeable b) => a -> m b -- | Acts as gFind but will throw an exception if nothing is found. gFind' :: (Data a, Typeable b) => a -> b -- | A generalized modify that will apply the modification function to the -- structure of the state. gModify :: (MonadState s m, Typeable a, Data s) => (a -> a) -> m () -- | A generalized ask that will traverse the stored type of the -- MonadReader in an attempt to find an a and will then apply -- the provided function if found. gAsk :: (Data r, Typeable a, MonadReader r m, MonadPlus n) => (a -> n b) -> m (n b) -- | The equivalent of gAsk for MonadState gGet :: (Data s, Typeable a, MonadState s m, MonadPlus n) => (a -> n b) -> c -> m (n b) -- | Normalizing Haskell values. module Happstack.Data.Normalize -- | The Normalize class provides a normalize function, which -- is intended to normalize values only at the top-level constructor, and -- a normalizeRecursively function, which is intended to normalize -- all the subvalues and then normalize the top-level constructor. -- -- There is a default instance that matches all types, where -- normalize is id and normalizeRecursively applies -- normalizeRecursively to all of its children and then -- normalize to the result. -- -- If you want to actually do some normalization for a certain type, then -- just define an instance for that type; this will take precedence over -- the default instance. class Data NormalizeD a => Normalize a normalize :: Normalize a => a -> a normalizeRecursively :: Normalize a => a -> a -- | This is the normalize function in the default Normalize -- instance. It may be a useful building block when writing your own -- instances. defaultNormalize :: Normalize a => a -> a -- | This is the normalizeRecursively function in the default -- Normalize instance. It may be a useful building block when -- writing your own instances. defaultNormalizeRecursively :: Normalize a => a -> a -- | When writing your own generic functions for Normalize you may -- need to access the class methods through this datatype rather than -- directly. data NormalizeD a NormalizeD :: (a -> a) -> (a -> a) -> NormalizeD a normalizeD :: NormalizeD a -> a -> a normalizeRecursivelyD :: NormalizeD a -> a -> a -- | When writing your own generic functions for Normalize you may -- need this, the proxy value. normalizeProxy :: Proxy NormalizeD instance [overlap ok] Data NormalizeD a => Normalize a instance [overlap ok] Normalize t => Sat (NormalizeD t) module Happstack.Data.Migrate -- | 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 -- | Provides default values for Haskell datatypes. module Happstack.Data.Default -- | The Default class provides a defaultValue value, which -- is the default value for that type. -- -- There is no instance for arbitrary types by default, but if you -- declare an instance without providing the value then one will be built -- using the first constructor. defaultValue is used to provide -- values for any arguments of the constructor. -- -- If you want an instance for all types then import -- Happstack.Data.Default.Generic. class Data DefaultD a => Default a defaultValue :: Default a => a -- | This is the defaultValue that is used in an instance if you -- don't specify one. It may be a useful building block when writing your -- own instances. defaultDefaultValue :: (Data DefaultD a, Default a) => a -- | When writing your own generic functions for Default you may -- need to access the class method through this datatype rather than -- directly. data DefaultD a DefaultD :: a -> DefaultD a defaultValueD :: DefaultD a -> a -- | When writing your own generic functions for Default you may -- need this, the proxy value. defaultProxy :: Proxy DefaultD instance [overlap ok] (Data DefaultD a, Ord a) => Default (Set a) instance [overlap ok] (Data DefaultD a, Data DefaultD b, Ord a) => Default (Map a b) instance [overlap ok] Default a => Default (ForeignPtr a) instance [overlap ok] Default Text instance [overlap ok] Default Text instance [overlap ok] Default ByteString instance [overlap ok] Default a => Default (Maybe a) instance [overlap ok] Default Char instance [overlap ok] (Default a, Default b, Default c, Default d) => Default (a, b, c, d) instance [overlap ok] (Default a, Default b, Default c) => Default (a, b, c) instance [overlap ok] (Default a, Default b) => Default (a, b) instance [overlap ok] Default () instance [overlap ok] (Default a, Default b) => Default (Either a b) instance [overlap ok] Default Double instance [overlap ok] Default Float instance [overlap ok] Default Integer instance [overlap ok] Default Word64 instance [overlap ok] Default Word32 instance [overlap ok] Default Word16 instance [overlap ok] Default Word8 instance [overlap ok] Default Word instance [overlap ok] Default Int64 instance [overlap ok] Default Int32 instance [overlap ok] Default Int16 instance [overlap ok] Default Int8 instance [overlap ok] Default Int instance [overlap ok] Data DefaultD a => Default [a] instance [overlap ok] Default t => Sat (DefaultD t) -- | Concisely specify which classes to derive for your datatypes. As well -- as the standard derivable classes, it can also derive syb-with-class's -- New.Data class and Happstack.Data.Default's Default -- class. module Happstack.Data.DeriveAll -- | The deriveAll function takes a list of classes to derive and a -- block of declarations. It will additionally derive instances for -- Typeable, Old.Data and New.Data. -- -- Example: -- --
--   $( 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] -- | Provides a Default instance for all types. -- defaultDefaultValue is used for defaultValue. module Happstack.Data.Default.Generic instance [overlap ok] Data DefaultD a => Default a 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[a7aG] :: DataType constr[a7aJ] :: Constr constr[a7aI] :: Constr constr[a7aH] :: 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[ag5P] :: DataType constr[ag5Q] :: Constr dataType[ag5F] :: DataType constr[ag5G] :: 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 User instance [overlap ok] Show User instance [overlap ok] Eq User instance [overlap ok] Data Pass instance [overlap ok] Show Pass instance [overlap ok] Eq Pass 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.Proxy -- | Proxy is empty and is used as a transport of a phantom type data Proxy t[aoZh] Proxy :: Proxy t[aoZh] dataType[aoZi] :: DataType constr[aoZj] :: 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] Data t[aoZh] => Data (Proxy t[aoZh]) instance [overlap ok] Read (Proxy t[aoZh]) instance [overlap ok] Show (Proxy t[aoZh]) instance [overlap ok] (Data ctx t[aoZh], Sat (ctx (Proxy t[aoZh]))) => Data ctx (Proxy t[aoZh]) instance [overlap ok] Typeable1 Proxy instance [overlap ok] Default t[aoZh] => Default (Proxy t[aoZh]) 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 getSafeGet :: Serialize a => Get (Get a) getSafePut :: Serialize a => PutM (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] Num (VersionId a) instance [overlap ok] Read (VersionId a) instance [overlap ok] Show (VersionId a) instance [overlap ok] Eq (VersionId a) instance [overlap ok] Show Object instance [overlap ok] Serialize Object instance [overlap ok] Version Object instance [overlap ok] Serialize AbsoluteTime instance [overlap ok] Version AbsoluteTime instance [overlap ok] Serialize NominalDiffTime instance [overlap ok] Version NominalDiffTime instance [overlap ok] Serialize DiffTime instance [overlap ok] Version DiffTime instance [overlap ok] Serialize LocalTime instance [overlap ok] Version LocalTime instance [overlap ok] Serialize ZonedTime instance [overlap ok] Version ZonedTime instance [overlap ok] Serialize TimeOfDay instance [overlap ok] Version TimeOfDay instance [overlap ok] Serialize TimeZone instance [overlap ok] Version TimeZone instance [overlap ok] Serialize UTCTime instance [overlap ok] Version UTCTime instance [overlap ok] Serialize UniversalTime instance [overlap ok] Version UniversalTime instance [overlap ok] Serialize Day instance [overlap ok] Version Day instance [overlap ok] Serialize Text instance [overlap ok] Version Text instance [overlap ok] Serialize Text instance [overlap ok] Version Text 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] (Integral a, Serialize a) => Serialize (Ratio a) instance [overlap ok] Typeable a => Version (Ratio a) 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