Just to weigh in with my thoughts on this other branch of the
conversation...

On Thu, Jul 30, 2015 at 06:39:19PM -0400, Aaron Wolf wrote:
>
> I know Bryan is talking about reimplementation already. Maybe he
> should post his plans / thoughts here.

Just to get people's brains churning and maybe prototyping, I
would like to see the following in a model layer:

1. Encapsulation of all relational algebra. Assuming we keep using
   a relational database (I am weakly in favor of doing so), we
   nonetheless want denormalization to be hidden from the controller
   actions[1] as much as possible. Ideally, a lot of handlers would
   just look like:

    getFooR = genWidgetFoo <=< fetchFooData
      where
        genWidgetFoo FooData{..} = widgetFile("foo")

or even smaller using type-directed stuff.

Rationale:

    (a) Allows us flexibility in implementing the model. Relational
        algebra is an implementation detail of how we persist data,
        and in spite of what the scaffolding would have you believe,
        persistence != model.

    (b) Allows point #2:

2. All relational algebra executed by the database. Thus, all those
   fetchFooData functions that encapsulate relational algebra would
   actually just be simple calls to database views.

Rationale:

    (a) Relational algebra is kind of mucky. Indices matter a lot
        for performance, as do realizing views, drawing transaction
        boundaries, and rewriting queries. There's no reason not to
        use the best tool for this job, especially since it looks like
        Opaleye will let us still write it in Haskell.

    (b) Encapsulation, again. If we decide to switch to Redis or
        whatever, there won't be a lot of gnashing of teeth adjusting
        the code that interacts with the model layer.

3. Take cues from FRP for implementing give-and-take interaction.
   Remove dependency on mutability.

Rationale:

    (a) immutability ftw.

This last point is way off in theory-land since I don't know of
anything like it, though I would not be surprised if it's out there.
The first two points, however, are something we should start planning
for.

[1]: controller actions have type Handler, btw

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Dev mailing list
[email protected]
https://lists.snowdrift.coop/mailman/listinfo/dev

Reply via email to