Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / THH.hs @ 71dc39a1

History | View | Annotate | Download (51.2 kB)

# Date Author Comment
7a51281a 02/18/2014 04:39 pm Jose A. Lopes

Fix whitespace and typos in comments

Signed-off-by: Jose A. Lopes <>
Reviewed-by: Hrvoje Ribicic <>

f20038fd 02/14/2014 11:46 am Petr Pudlak

Another workaround for GHC linking error "unknown symbol"

This error appears after adding the dependency to lifted-base.
See also #683 and ee7caf27.

I surmise that something like this is happening: Some code, that uses
the library, is only referenced through Template Haskell. A probable bug...

b775af80 02/04/2014 04:12 pm Klaus Aehlig

Assert correct usage of AndRestArguments fields

The special field andRestArguments is intended to be only used
as the last field of an object, catching all remaining keys.
Add a compile-time check to verify that it is used correctly.

Signed-off-by: Klaus Aehlig <>...

45907709 02/04/2014 03:14 pm Petr Pudlak

Merge branch 'stable-2.11' into master

  • stable-2.11
    Add andRestArguments to IDiskParams
    Add function providing the canonical andRestArguments
    Add genAndRestArguments :: Gen (Map String JSValue)
    Add additional constructor AndRestArguments to OptionalType...
4e4821bd 02/04/2014 10:51 am Klaus Aehlig

Add function providing the canonical andRestArguments

The field catching the remaining fields will always be of the same
shape, so add a function for this to make usage simple.

Signed-off-by: Klaus Aehlig <>
Reviewed-by: Petr Pudlak <>

c2442429 02/04/2014 10:51 am Klaus Aehlig

Add additional constructor AndRestArguments to OptionalType

A field of this type will capture all the remaining fields
of an object as JSValues. Obviously, the intended use is
to have precisely one such field. This mechanism will allow
to pass opaque values trough, as it is, e.g., required for...

b9202225 01/29/2014 03:59 pm Petr Pudlak

Replace duplicated code with readJSONWithDesc

JSON errors were annotated at other places, so use the function there as
well.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

a3dabca9 01/29/2014 03:59 pm Petr Pudlak

When parsing fields, annotate JSON errors with names

This allows better debugging of failed JSON conversions.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

74b3f734 01/16/2014 05:11 pm Petr Pudlak

Use ClockTime instead of Double in fields in Objects.hs

This affects "mtime" and "ctime" fields in all data types.

This also forces explicit declaration of how the fields are serialized
in Query.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

836ccf52 01/16/2014 05:11 pm Petr Pudlak

A function for creating time fields that serialize as Double

The function creates fields with custom read/show methods based on
TimeAsDoubleJSON, with the default value of 0 seconds since the epoch.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

d8adc255 01/16/2014 05:11 pm Petr Pudlak

Document Field data type used in TH code generation

Describe what types of fields are currently possible and allowed and
what what are the types of their "Q Exp" expressions.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

596d7b4f 01/16/2014 05:10 pm Petr Pudlak

Prohibit fields that are optional with a default value

For fields marked optional we need to keep the information that a value
isn't available. Therefore having a default value for an optional field
would not work.

Signed-off-by: Petr Pudlak <>...

ee7caf27 01/16/2014 05:10 pm Petr Pudlak

A workaround for GHC linking problem "unknown symbol ..."

GHC 7.4 on Debian Wheezy fails to compile after some TH related changes,
reporting

ghc: src/Ganeti/JSON.o: unknown symbol
`attoparseczm0zi11zi1zi0_DataziAttoparsecziText_zdwf_info`

This doesn't happen on Squeeze. Explicitly importing attoparsec in THH...

eb577716 01/16/2014 05:10 pm Petr Pudlak

Fix saveObjectField to work properly with custom fieldShow

Before it only worked for non-optional fields. For optional fields
with custom fieldShow functions, the generated code didn't use it.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

0b7bf465 01/16/2014 05:10 pm Petr Pudlak

Fix typing problems in TH that generates field code

See #677: The code generated by TH had different types depending on if
a field had a default value and/or custom reader. Simple cases worked by
accident, but more complex ones failed.

This patch distinguishes properly between optional fields and mandatory...

6897a51e 12/13/2013 02:58 pm Petr Pudlak

Use a data type when generating Python types of OpCodes

Currently they are generated only as Strings.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Jose A. Lopes <>

0d78accc 12/13/2013 02:58 pm Petr Pudlak

Refactor OpCodeDescriptor from a tuple to a data type

This greatly enhances code readability.

Also fix monadic types "Q ExpQ" [which is "Q (Q Exp)"] to "Q Exp".

Signed-off-by: Petr Pudlak <>
Reviewed-by: Jose A. Lopes <>

b711450c 12/13/2013 02:58 pm Petr Pudlak

Rename PyValueInstances.hs to PyValue.hs

Now the file contains the type class declaration as well.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Jose A. Lopes <>

2886c58d 12/13/2013 02:58 pm Petr Pudlak

Move PyValue into PyValueInstances.hs, import it in THH.hs

This puts all PyValue code into one module, getting rid of orphan
instances.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Jose A. Lopes <>

5b4ed56e 12/03/2013 12:50 pm Klaus Aehlig

Support fieldRead in partial params

While from parameters both full and partial versions are generated,
with in the partial version all types mapped to Maybe, the fieldRead
parameter of the field was not wrapped accordingly. So far, that didn't
matter, as it was always Nothing in this case, but for supporting special...

ba0d1405 12/03/2013 12:50 pm Klaus Aehlig

Add a field-transformer for accepting parser

Add a transformer for numerical fields, to also accept
strings instead of numbers if they can be parsed by the
given parser.

Signed-off-by: Klaus Aehlig <>
Reviewed-by: Hrvoje Ribicic <>

47ea2344 10/28/2013 12:04 pm Jose A. Lopes

Hs2Py constants: add 'becDefaults'

Add constant 'becDefaults' to the Haskell to Python constant
generation. An instance of 'PyValue' is added to the type 'PyValueEx'
in order to allow polymorphic types, namely, 'Map's.

Signed-off-by: Jose A. Lopes <>...

85bcb1de 10/28/2013 12:04 pm Jose A. Lopes

Remove 'Show' from 'PyValue' class

Remove 'Show' constraint from the 'PyValue' class which, even though
it allowed to simplify the definition of instances of this class for
primitive types, it made it more complicated to define instances for
other types....

a48daa87 10/08/2013 03:50 pm Jose A. Lopes

Add 'declareILADT' to declare integer literal datatypes

Add 'declareILADT' to declare integer literal datatypes.

Signed-off-by: Jose A. Lopes <>
Reviewed-by: Thomas Thrainer <>

e82d1e98 09/18/2013 02:33 pm Jose A. Lopes

Add Template Haskell 'declareLADT'

Add 'declareLADT' in Template Haskell module to declare Haskell
datatypes using 'String's directly as values for the JSON
serialization, as opposed to 'Name's which is what the current
'declareADT' allows. To achieve this, 'genFromRaw' must be...

4651c69f 09/10/2013 11:58 am Jose A. Lopes

Wrap 'Set' in 'ListSet' for the opcodes

In what Haskell to Python opcodes are concerned, a Haskell 'Set' is
translated into a Python 'list'. In other words, currently, opcodes
that handle sets of parameters are actually handling lists because
this is how sets are currently encoded. This patch introduces a new...

ce1b0c05 08/29/2013 04:05 pm Jose A. Lopes

Haskell to Python opcodes: fix Unit

Fix how Haskell to Python opcode generation handles unit. It seems
that, in 'template-haskell-2.7.0', unit is represented by Template
Haskell as a constructor of the form '(ConT name)', where 'name' is
the constructor name for 'Unit'. However, in 'template-haskell-2.8.0'...

d34c79b6 08/29/2013 01:17 pm Jose A. Lopes

Add Template Haskell code for constant generation

Add Template Haskell functions that generate a list in Haskell
containing all the constants to be generated in Python. This list is
an association list mapping the constant name to its Python value,
which is stored as a string....

34af39e8 08/07/2013 10:41 am Jose A. Lopes

Add Python opcode generation

  • add Python opcode generation to Template Haskell
  • fix all the opcodes and parameters, including their types and
    documentation
  • update Luxi to reflect the other changes.

Signed-off-by: Jose A. Lopes <>...

bcba4e01 05/03/2013 11:38 am Michele Tartara

Merge stable-2.7 into stable-2.8

Conflicts:
INSTALL
NEWS
configure.ac
src/Ganeti/Query/Group.hs
test/hs/Test/Ganeti/Objects.hs
test/hs/Test/Ganeti/Query/Query.hs

Signed-off-by: Michele Tartara <>
Reviewed-by: Helga Velroyen <>

61f3d56e 04/29/2013 05:48 pm Klaus Aehlig

Fix typo in documentation string

Signed-off-by: Klaus Aehlig <>
Reviewed-by: Helga Velroyen <>

08f7d24d 02/25/2013 11:36 am Iustin Pop

Improve TemplateHaskell code to support empty objects

Currently, an empty objects will generate warnings as the arguments of
various functions are unused. By adding conditional code for this, we
can support generation of empty objects, e.g. like needed in Rpc code....

3add7574 12/24/2012 11:38 pm Iustin Pop

Rename htools/ to src/

Per offline discussions, this is the first patch of the
renames. Tested with "make distcheck", seems to work fine.

The only change outside of the renaming is a bit of simplification in
the .gitignore rules; otherwise, simply s/htools/src/....