1 {-# OPTIONS -fallow-undecidable-instances #-}
5 import Text.XML.HaXml.XmlContent
7 -- | The @InfoKind@ class is a predicate that ensures we can always create
8 -- at least a blank (empty) information element, that we can read and
9 -- write them to/from the user, and that there exists some method of
10 -- determining the correctness of the value (completeness/consistency etc)
11 -- against some global type.
12 class (Eq a, Show a, Parse a, XmlContent a) => InfoKind a g | a -> g where
14 check :: String -> g -> a -> [String] -- returns warnings
15 -- ^ first arg is container label for error reporting.
16 -- second arg is global value
18 -- A basic instance representing "no info"
19 instance InfoKind () () where
22 -- Assume that info is mandatory, but not supplied a priori.
23 instance InfoKind a b => InfoKind (Maybe a) b where
25 check n _ Nothing = ["No info value stored with "++n]
26 check n g (Just a) = check n g a