What replaces the MVC pattern in functional programming?
Asked Answered
G

4

10

I'm a MVC web developer who's become very interested in functional programming to write web apps (specifically, I'm captivated by Erlang and Cowboy.)

What I'm having trouble finding an answer to/resources on is what pattern is used to replace MVC in FP.

Obviously the idea of an ORM is ludicrous in FP, since it's not object oriented, so what is used to replace it for persistence logic? Is it usual to just build a module that uses a library to create functions that interface with the datastore, or are there tools similar to ORMs?

Both advice and links to resources would be greatly appreciated. Bonus points for Erlang/Cowboy specific help. Thanks.

Galba answered 5/6, 2013 at 1:1 Comment(2)
This question lends a bit of help to me understanding why this answer seems to be missing, but I'm still interested in advice from people experienced with FP, specific to ORM-type work.Galba
Have a look at Deprecating the Observer Pattern with Scala.React.Henryson
G
5

There are MVC frameworks for Erlang. It's ChicagoBoss for example.

Geez answered 5/6, 2013 at 3:55 Comment(2)
Thank mate. I've had a look at ChicagoBoss, and am thinking I'd prefer to go with something slimmer like Cowboy or WebMachine. I realise this means the ORM-equivalent isn't baked in, but am trying to figure out how FPers do it in general, without an ORM.Galba
You might want to have a look at nitrogenproject.com - it's not quite MVC (it is event-driven using Erlang pattern matching). I found it to be light weight with a fast development cycle. BTW, there is less need for ORM-like tools in Erlang since databases such as Mnesia allow terms to be stored in the database and read back as terms, i.e. there is no need for a mapping or translation layer as there's nothing to translate.Goshorn
A
4

Quoting from an article by @yarivs:

Erlang does carry its weight in all letters of the MVC. For the Model, forget database abstraction layers: you have a pure Erlang distributed database called Mnesia. For the view, Yaws has ehtml. For the controller, Yaws has appmods and Erlang's pattern matching.

I hope this helps.

Abrego answered 17/8, 2013 at 7:25 Comment(0)
D
2

im a coder for erlang. i use erlang for my web-game server... so...there is no View..and in function luangues this is no Model... so from my point of view, function luangues there is no need of MVC (just like no class or subclasses in function luangues..)

Dendy answered 12/7, 2013 at 3:38 Comment(0)
F
1

Lift framework(written in Scala) uses pattern called 'view first'.

follow link https://www.assembla.com/wiki/show/liftweb/View_First

Frivolous answered 3/7, 2013 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.