[web-devel] A few questions about Yesod
michael at snoyman.com
Thu Dec 30 14:09:16 CET 2010
Very good questions, answers below.
On Thu, Dec 30, 2010 at 1:01 PM, Iustin Pop <iustin at google.com> wrote:
> Hi all,
> I just started looking at Yesod and its associated libs (hamlet, etc.)
> and it is very interesting, thanks.
> However, I'm confused by a few things and the docs are not helping, so
> please bear my beginner questions.
> First: hamlet uses '.' as function application, instead of the usual
> space. How can I then use a qualified name (e.g. Data.List.nub)? If I
> use it normally, it errors out on me. Must be something very trivial but
> I cannot find a way.
Hamlet uses both '.' and space as function application, and therefore
qualified names are not supported. I work around this usually by
creating an alias for the function I want locally. I know this can be
inelegant; if you have any ideas, I'm all ears.
> Second: Yesod.Json says “Due to the limited nature of the JSON format,
> you can create any valid JSON document you wish using only jsonScalar,
> jsonList and jsonMap”. This seems false to me, as jsonScalar only deals
> with JSON strins, and not JSON numbers or the constants (true, false,
> null). In the meantime I'm using a hack for numbers using jsonRaw, but I
> think some more functionality needs to be added to it for non-trivial
Quite correct. I'm working on Yesod 0.7 right now, which will be
offloading the JSON work to John Millikin's json-types package which
properly supports numbers, booleans and nulls.
> And last: I don't understand how runDB and the persistent framework is
> supposed to do error handling. Case in point: let's say one tries to
> insert a duplicate unique key in a table, which fails as expected "user
> error (SQLite3 returned ErrorConstraint while attempting to perform
> step.)". The problem is any other use of that particular REST resource,
> even with different parameters, results in "user error (SQLite3 returned
> ErrorMisuse while attempting to perform bind text.)", and I don't know
> if this is due to my usage of the framework or due to something else.
> The interesting part is that other resources are working fine.
That sounds like a bug in the SQLite backend to be honest. Could you
send me a test case that breaks it? It is much appreciated.
More information about the web-devel