5

I was under the impression that there are folks out there that do write pure applications using Scalaz, but based on this example: [ stacking StateT in scalaz ], it looks like anything real would also be impossibly hairy.

Are there any guidelines or examples of real, modular, loosely-coupled, pure applications in Scala? I'm expecting that this means scalaz.effect.SafeApp and RWST over IO, but I'd like to hear from folks who have done it.

Thanks.

Edit: In the absence of an answer, I've started collecting resources as an answer below. If you have any examples or related links to contribute, please do.

Community
  • 1
  • 1
arya
  • 946
  • 5
  • 14

2 Answers2

1

i think you are mixing two different things. one is pure functional programming and second is scala type system. you can do 'pure' programming in any language, even in java. if the language is funvtional than you will have pure functional programming.

  • does it make your programs work faster? depends on the program - it scales better but for single threaded parts you will rather loose performance.
  • does it 'save your cognition'? it depends on how good you are in what you are doing. if you work with FP, monads, arrows etc on the daily basis then i assume it may help significantly. if you show the code to the OO developer he probably won't understand anything.
  • does it save the development time? as previously, i think it may but to be honest it doesn't matter that much. you more often read the code rather than write it
  • can you do useful stuff in PFP? yes, some companies makes money on haskell

and now, can it be done in scala? for sure. will anyone do it in scala? probably not because it's too easy to break the purity, because type system is too weak and because there are better, 'more pure' tools for it (but currently not on jvm)

piotrek
  • 13,982
  • 13
  • 79
  • 165
  • Thanks - a few questions: 1) It sounds like you're saying that people don't use PFP in Scala, because it's not practical, despite the existence of Scalaz: purity isn't guaranteed, and the syntactic overhead is high due to inferior type inference. Is that correct? 2) Re "saving cognition" / development time, I didn't quite follow your meaning. Reading code is presumably part of development too, and nobody will understand even OO before they're exposed to it. I don't think you mean that PFP is only useful for people who are already doing PFP; so I wasn't sure what to take from this. – arya May 13 '14 at 19:12
  • 1) i'm not saying 'it's not practical. rest is correct. 2) procedural and OO is kind of 'default' approach. usually that's what people learn first. so later you have to learn programming again - the functional way – piotrek May 14 '14 at 00:14
  • I thought that in the final paragraph after the bulleted list, you were saying it wasn't practical in scala. If I misunderstood, could you clarify the last paragraph? – arya May 14 '14 at 15:15
1

I guess I will start collecting resources here, and update as I find more.

arya
  • 946
  • 5
  • 14