On Tue, Aug 27, 2013 at 3:38 PM, Jose A. Lopes <[email protected]> wrote: > From: "Jose A. Lopes" <[email protected]> > > Move some 'PyValue' instances to a separate file so they can be > available to other modules which need these instances but do not want > to depend on the constants module, which led to compilation > constraints. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > Makefile.am | 1 + > src/Ganeti/OpCodes.hs | 23 +---------------- > src/Ganeti/PyValueInstances.hs | 58 > ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 60 insertions(+), 22 deletions(-) > create mode 100644 src/Ganeti/PyValueInstances.hs > > diff --git a/Makefile.am b/Makefile.am > index ccc0004..95bafb4 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -621,6 +621,7 @@ HS_LIB_SRCS = \ > src/Ganeti/OpParams.hs \ > src/Ganeti/Path.hs \ > src/Ganeti/Parsers.hs \ > + src/Ganeti/PyValueInstances.hs \ > src/Ganeti/Query/Cluster.hs \ > src/Ganeti/Query/Common.hs \ > src/Ganeti/Query/Export.hs \ > diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs > index 45dec90..7633bf0 100644 > --- a/src/Ganeti/OpCodes.hs > +++ b/src/Ganeti/OpCodes.hs > @@ -52,36 +52,15 @@ import Ganeti.THH > > import qualified Ganeti.Hs2Py.OpDoc as OpDoc > import Ganeti.OpParams > +import Ganeti.PyValueInstances () > import Ganeti.Types > import Ganeti.Query.Language (queryTypeOpToRaw) > > import Data.List (intercalate) > import Data.Map (Map) > -import qualified Data.Map as Map > -import Data.Set (Set) > -import qualified Data.Set as Set > > import qualified Ganeti.Constants as C > > -instance PyValue Bool > -instance PyValue Int > -instance PyValue Double > -instance PyValue Char > - > -instance (PyValue a, PyValue b) => PyValue (a, b) where > - showValue (x, y) = show (showValue x, showValue y) > - > -instance PyValue a => PyValue [a] where > - showValue xs = show (map showValue xs) > - > -instance PyValue a => PyValue (Set a) where > - showValue s = showValue (Set.toList s) > - > -instance (PyValue k, PyValue a) => PyValue (Map k a) where > - showValue mp = > - "{" ++ intercalate ", " (map showPair (Map.assocs mp)) ++ "}" > - where showPair (k, x) = show k ++ ":" ++ show x > - > instance PyValue DiskIndex where > showValue = showValue . unDiskIndex > > diff --git a/src/Ganeti/PyValueInstances.hs b/src/Ganeti/PyValueInstances.hs > new file mode 100644 > index 0000000..a1aad47 > --- /dev/null > +++ b/src/Ganeti/PyValueInstances.hs > @@ -0,0 +1,58 @@ > +{-| PyValueInstances contains instances for the PyValue typeclass. > + > +-}
Can you expand a bit more this docstring please. How would you explain this to my grandfather? (ok, ok, not to my grandfather, but maybe to a developer not too familiar with Ganeti or Haskell?) :) Thanks, Guido
