[Haskell-beginners] How to "cast" FromJSON instance value

Jan von Löwenstein jan.loewenstein at gmail.com
Tue Aug 1 10:45:19 UTC 2017


You don't know anything about your a's but that they have FromJSON
instances. That in turn means you can get values from aeson parsing
functions. Think parseJSON :: Value -> Parser a
Could you be more specific about the problem you try to solve?


Baa <aquagnu at gmail.com> schrieb am Di., 1. Aug. 2017, 10:32:

> Hello, List!
> I have, for example, function with signature like
>   fn :: FromJSON a => Map Text a -> BlahBlah
> and I want to treat this `a` as String (or `Text`), to read it with
> `readMaybe`. Am I right that it's impossible? I get error about "...a
> is rigid type and could not be matched with Text...". But `Text` is
> `FromJSON` instance. Is it possible to do it (cast, convert, unwrap, etc)?
> The problem's source is that early I worked with `Text` values only
> (getting from HTML form) but now they become any type: int's, bool's,
> etc).
> ===
> Best regards,
>   Paul
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170801/71edafd8/attachment.html>

More information about the Beginners mailing list