[Haskell-beginners] type vs data, again...
Emmanuel Touzery
etouzery at gmail.com
Sun Mar 17 14:27:35 CET 2013
Hi,
thank you for the tip! It helps but it's not quite there yet. If you see
the program in attachment, I can make it compile only by commenting the
type declaration for the second function, otherwise it's the exact same
error message as before.
In -Wall the compiler does suggest me the signature, but it's not
enlightening for me at this point, I've yet to dig that deep in haskell's
type system:
parseConfigMap :: forall t (m :: * -> *). Monad m => t -> m ()
Can you explain me why my type signature is not correct?
Thank you again!
Emmanuel
On Sun, Mar 17, 2013 at 1:23 PM, Andres Löh <andres at well-typed.com> wrote:
> Hi there.
>
> > -- | A JSON \"object\" (key\/value map).
> > type Object = Map Text Value
>
> See https://github.com/bos/aeson/blob/master/release-notes.markdown
>
> Quoting:
>
> "
> 0.3 to 0.4
>
> [...]
>
> We switched the intermediate representation of JSON objects from
> Data.Map to Data.HashMap, which has improved type conversion
> performance.
> "
>
> > So my clearly flawed plan is to get the value, pattern mach it against
> > (Object hash) and then work on the hash. However for the program in
> > attachment, which I would expect to compile, I get this compile error:
> >
> > question.hs:12:62:
> > Couldn't match expected type `Map.Map T.Text Value'
> > with actual type `Object'
> > In the first argument of `parseConfigMap', namely `map'
> > In the second argument of `($)', namely `parseConfigMap map'
> > In the expression: return $ parseConfigMap map
>
> This has nothing to do with "type" vs. "data". The type synonym
> expansion of Object doesn't match your type, because it uses a HashMap
> rather than a Map.
>
> Cheers,
> Andres
>
> --
> Andres Löh, Haskell Consultant
> Well-Typed LLP, http://www.well-typed.com
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130317/c7e2990e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: question.hs
Type: application/octet-stream
Size: 432 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130317/c7e2990e/attachment.obj>
More information about the Beginners
mailing list