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.

iliveinapark
  • 327
  • 4
  • 13
  • [This question](http://stackoverflow.com/questions/327955/does-functional-programming-replace-gof-design-patterns) 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. – iliveinapark Jun 05 '13 at 01:09
  • Have a look at [Deprecating the Observer Pattern with `Scala.React`](http://infoscience.epfl.ch/record/176887). – lukstafi Jun 05 '13 at 13:02

4 Answers4

5

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

Danil Onishchenko
  • 2,030
  • 11
  • 19
  • 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. – iliveinapark Jun 06 '13 at 01:44
  • You might want to have a look at http://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. – Paul Cager Jun 06 '13 at 12:13
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.

Ning
  • 2,850
  • 2
  • 16
  • 23
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..)

new7877
  • 87
  • 2
1

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

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

Adi
  • 2,364
  • 1
  • 17
  • 23