LGTM, thanks.

On Tue, Feb 4, 2014 at 3:01 PM, Klaus Aehlig <[email protected]> wrote:

> 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 <[email protected]>
> ---
>  src/Ganeti/THH.hs | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/Ganeti/THH.hs b/src/Ganeti/THH.hs
> index bbcc9b8..6a7bfa4 100644
> --- a/src/Ganeti/THH.hs
> +++ b/src/Ganeti/THH.hs
> @@ -955,6 +955,10 @@ fieldTypeInfo field_pfx fd = do
>  -- | Build an object declaration.
>  buildObject :: String -> String -> [Field] -> Q [Dec]
>  buildObject sname field_pfx fields = do
> +  when (any ((==) AndRestArguments . fieldIsOptional)
> +         . drop 1 $ reverse fields)
> +    $ fail "Objects may have only one AndRestArguments field,\
> +           \ and it must be the last one."
>    let name = mkName sname
>    fields_d <- mapM (fieldTypeInfo field_pfx) fields
>    let decl_d = RecC name fields_d
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>

Reply via email to