[Ur] Function `queryL1` returns type `transaction (list $fs)` - How can I get the `list $fs` part and pass it to `List.mapX` - which expects type `list`?
Stefan Scott Alexander
stefanscottalexx at gmail.com
Mon Jul 20 00:15:06 EDT 2015
I understand if Adam doesn't want to be the one to deal with newbie
questions. Look at the amazing achievement of the Ur/Web compiler - he
created that, and the mindset needed to create that is probably quite
different than the mindset needed to deal with monadic newbies like me. So
I do understand that. I just wish the community were big enough so that
there would be someone out there who could give me some pointers on where
my code is wrong.
In a situation where the student is actively researching all the available
(albeit scarce) literature and examples and proposing a bunch of half-baked
solutions himself, then correcting them by offering a tiny but specific
suggestion or a hint, perhaps even based on the code he already wrote, can
be very helpful pedagogically - because in this situation, the student is
totally immersed in the details of the solutions he has proposed, in
relation to the examples he is emulating in the literature, and is really
receptive to any new information.
So a tiny (but specific) push in any direction can be really useful -
because it would be highly specific to the actual current understanding of
the student, in relation to the specifics of what he's seen, and the
specifics of what he's attempted, to where the student's "head" is at, at
this point on his path of trying to grasp monadic transactions in Ur/Web.
When a student is struggling with the syntax for a specific task in a
language and actively experimenting by making and submitting different
proposed solutions using a variety of syntactical alternatives, and also
providing detailed informal rationales of how he thinks a particular
approach works, or why he thinks his approach is not working, and asking
specific questions about certain details of the approaches he's attempting
to use and certain details of the examples in the literature, then that can
be a great teaching moment which should not be wasted.
Just saying "go out and find some book on this general topic in some
related language" really wastes a major teaching opportunity to gently
nudge the student in the right direction onto the right track at a time
when he is highly motivated and totally immersed in the details of this
particular issue.
A mere one-liner could be all that it takes - an English-language
pseudo-code version of how to run a transactional SQL SELECT and pass the
results on to build an XML fragment. Just saying: "you need to use the `<-`
notation" (or you DON'T need to use the `<-` notation - I have no idea, I'm
the one who's confused here), "And then you need to do this with the result
in order to hand it off to that function..." - this would take less time to
say than writing "I haven't read your post".
One last desperate plea for a shred of information: I do know that when
something returns an Option, you have to use a case statement on Some or
None to basically "unbox" it to get the non-monadic value out. Option is a
monad. Here I'm dealing with a differnent Monad: a Transaction. I
understand conceptually that I'm getting a `transaction (list $fs)` but I
need a `list $fs`. Is there some way to "unbox" the transaction to get the
non-monadic value out of it - the way we "unbox" an Option?
I'm not sure me going back and reading more Haskell monad tutorials is the
best approach any more. I've been doing that for about a year, and I have
some grasp of monads now. It would not be harmful (in fact it would be
highly pedagogical) to see an example of the correct use of a monadic
transaction to run some SQL and build some XML from that, as I have been
trying to do in my code.
I think the biggest leap forward in my understanding of monads would occur
if I could finally see (or if someone could gently nudge me towards writing
myself, based on the erroneous attempts I've made so far and submitted in
various threads on this mailing list - eg, the erroneous attempt in the
original post in this particular thread), if I could finally see the
example of a monadic transaction running some SQL and passing that along to
create an XML fragment.
If someone would just point out what I'm doing wrong, then I would really
learn a lot from being corrected that way.
- Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150720/e0ee10c0/attachment.html>
More information about the Ur
mailing list