[Ur] An Ur/Web implementation of TodoMVC

Torstein Saltvedt torstein.saltvedt at gmail.com
Tue Jun 17 14:15:36 EDT 2014


This gives me an opportunity to ask something which I've wondered for a
while. I only know some very, very basic Haskell and I'm subscribed to this
mailing list just because I'm fascinated by Ur/Web. After doing web
development in PHP, I switched to Ruby on Rails roughly two years ago. Most
people who will read the Ur/Web implementation of TodoMVC will probably be
a bit like me, experienced web developers who are curious on functional
programming.

When I read the source code, I can't help but think: *isn't this code
really bad?*

And I don't mean to criticize here; I genuinely know nothing about what
makes good or bad functional code.

When you start learning Haskell, you're told to "forget everything you
think you know about programming". Which is okay, using recursion instead
of loops makes sense to me now, though it took a bit of time and mind
bending. In the end it turned out to just be different from what I were
used to doing.

But here you place the entire logic and presentation of the application in
a single 150 lines of code long function.

It reminds me about the awful SQL/HTML spaghetti I wrote when I first
started learning programming with PHP. And while the Ur/Web code is
probably totally fine with all it's fancy type-checking and whatnot, it
looks *really* *scary* to my object oriented eyes.

What about keeping code DRY? Separation of concerns? Preventing too many
levels of nesting? Keeping functions short and testable? Encapsulation?

If you wanted to change the TodoMVC implementations of the mainstream
javascript frameworks to use persistence you would only need to change the
models. The rest of the application would stay the same. (Let's just ignore
the actual REST API.)

I know it is asking a lot, but I would love to see how this would be
refactored to use Ur/Webs database persistence.



On Sun, Jun 15, 2014 at 3:37 PM, Adam Chlipala <adamc at csail.mit.edu> wrote:

>  Some of you may be familiar with TodoMVC <http://todomvc.com/>, a
> project to compare different client-side web frameworks via implementation
> of a common task.
>
> I recently put up an Ur/Web implementation
> <http://www.impredicative.com/ur/todomvc/>.  I've poked
> <https://github.com/tastejs/todomvc/issues/912> the TodoMVC maintainers
> on GitHub about including the Ur/Web code in their next release; we'll see
> how it goes!  The Ur/Web app is different from most of their solutions in a
> few ways that should make for some interesting negotiation.
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>
>


-- 
Torstein Saltvedt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20140617/9ff39e30/attachment.html>


More information about the Ur mailing list