jims | 26 Jan 14:47 2013

aeson-0.6.1.0 deriveJSON error

ghc doesn't seem to be unifying deriveJSON (String->String)
parameter with id :: a -> a.

examples/TemplateHaskell.hs:22:14:
     Couldn't match expected type `Data.Aeson.TH.Options'
                 with actual type `a0 -> a0'
     In the first argument of `deriveJSON', namely `id'
     In the expression: deriveJSON id ''Coord
ghc --make: /usr/hs/ghc/7.4.1/bin/ghc failure (return code=1)

ghc-7.4.1 x86_64
Centos-6

[jim <at> localhost aeson]$ ghc-pkg list  
--package-conf=../cabal-dev/packages-7.4.1.conf
../cabal-dev/packages-7.4.1.conf
    HTTP-4000.2.6
    aeson-0.6.1.0
    attoparsec-0.10.3.0
    attoparsec-conduit-0.5.0.3
    base-unicode-symbols-0.2.2.4
    blaze-builder-0.3.1.0
    blaze-builder-conduit-0.5.0.3
    case-insensitive-0.4.0.4
    conduit-0.5.6
    dlist-0.5
    hashable-1.2.0.5
    http-types-0.7.3.0.1
    lifted-base-0.2.0.2
    monad-control-0.3.1.4
(Continue reading)

Bas van Dijk | 26 Jan 15:20 2013
Picon

Re: aeson-0.6.1.0 deriveJSON error

On 26 January 2013 14:47,  <jims <at> stuttard.org> wrote:
> ghc doesn't seem to be unifying deriveJSON (String->String)
> parameter with id :: a -> a.

It seems you're using aeson HEAD. Note that the deriveJSON from the
released aeson-0.6.1.0 as the type:

  deriveJSON :: (String -> String) -> Name -> Q [Dec]

But in aeson-HEAD it has the following type:

  deriveJSON :: Options -> Name -> Q [Dec]

Cheers,

Bas
Bas van Dijk | 26 Jan 15:34 2013
Picon

Re: aeson-0.6.1.0 deriveJSON error

On 26 January 2013 15:20, Bas van Dijk <v.dijk.bas <at> gmail.com> wrote:
> But in aeson-HEAD it has the following type:
>
>   deriveJSON :: Options -> Name -> Q [Dec]

Note that I'm currently working on extending the encoding Options record:

* I added a constructorNameModifier :: String -> String which is
applied to constructor names and is handy for lower-casing them for
example.

* I extended the sumEncoding with a ObjectWithSingleField constructor
which causes a constructor to be encoded to an object with a single
field named after the constructor (modified by the
constructorNameModifier) and the value will be the contents of the
constructor.

* I'm also modifying the GHC Generics code to take the encoding
Options into account.

This work is happening in my parameterize-generic-encoding-with-options branch:

https://github.com/basvandijk/aeson/commits/parameterize-generic-encoding-with-options

Bas
jims | 26 Jan 16:40 2013

Re: aeson-0.6.1.0 deriveJSON error

Quoting Bas van Dijk <v.dijk.bas <at> gmail.com>:

> On 26 January 2013 15:20, Bas van Dijk <v.dijk.bas <at> gmail.com> wrote:
>> But in aeson-HEAD it has the following type:
>>
>>   deriveJSON :: Options -> Name -> Q [Dec]

> Note that I'm currently working on extending the encoding Options record:
>
> * I added a constructorNameModifier :: String -> String which is
> applied to constructor names and is handy for lower-casing them for
> example.
>
> * I extended the sumEncoding with a ObjectWithSingleField constructor
> which causes a constructor to be encoded to an object with a single
> field named after the constructor (modified by the
> constructorNameModifier) and the value will be the contents of the
> constructor.
>
> * I'm also modifying the GHC Generics code to take the encoding
> Options into account.
>
> This work is happening in my  
> parameterize-generic-encoding-with-options branch:

Both hackage and your branch build TemplateHaskell.hs ok.
I'll try and understand what you've done :)

Cheers

(Continue reading)

jims | 26 Jan 16:23 2013

Re: aeson-0.6.1.0 deriveJSON error

Quoting Bas van Dijk <v.dijk.bas <at> gmail.com>:

> On 26 January 2013 14:47,  <jims <at> stuttard.org> wrote:
>> ghc doesn't seem to be unifying deriveJSON (String->String)
>> parameter with id :: a -> a.
>
> It seems you're using aeson HEAD. Note that the deriveJSON from the
> released aeson-0.6.1.0 as the type:

Thanks for the instant help :) Now I know that
versions numbers on github don't necessarily get bumped
if there's a breaking change. I got confused when I found
the hackage documentation was different .

Cheers

>   deriveJSON :: (String -> String) -> Name -> Q [Dec]
>
> But in aeson-HEAD it has the following type:
>
>   deriveJSON :: Options -> Name -> Q [Dec]
>
> Cheers,
>
> Bas
>

Gmane