0
votes
2answers
71 views

On a service interface, expose doSomethingOnUser(user: User) or doSomethingOnUser(userId: String)

I'm using Scala in this question but I'm also ok for an answer in Java or any other language. I can expose a service with the following: def doSomethingOnUser(user: User): Result The problem is: ...
6
votes
4answers
188 views

Multiple flatMap methods for a single monad?

Does it make sense to define multiple flatMap (or >>= / bind in Haskell) methods in a Monad? The very few monads I actually use (Option, Try, Either projections) only define one flatMap method. ...
4
votes
1answer
163 views

Scala: Bad inferred type for Option composed with StateT monad transformer

I'm somewhat familiar with Haskell monad transformers, but new to Scalaz (version 7). I made (what I thought was) a straightforward translation from the following Haskell code: import ...
2
votes
1answer
117 views

scala - Analog of Haskell's sequence [duplicate]

What is the scala analog of Haskell's sequence function? http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:sequence sequence is defined in Haskell as follows: sequence ...
9
votes
2answers
285 views

Function Overhead in Functional Languages like Haskell or in Hybrids like Scala [closed]

Coming from imperative languages like Python, Javascript and Java, I was very often reading about function overhead and why to avoid map from a performance perspective. Obviously these are no ...
153
votes
3answers
11k views

What does “coalgebra” mean in the context of programming?

I have heard the term "coalgebras" several times in functional programming and PLT circles, especially when the discussion is about objects, comonads, lenses, and such. Googling this term gives pages ...
2
votes
1answer
106 views

scanr1 in Scala?

In Scala, is there a scanr1, similar to Haskell's scanr1 which takes no zero-element and produces the intermediate results that would otherwise be created by an in-order reduce operation?
21
votes
4answers
525 views

How to concisely express function iteration?

Is there a concise, idiomatic way how to express function iteration? That is, given a number n and a function f :: a -> a, I'd like to express \x -> f(...(f(x))...) where f is applied n-times. ...
15
votes
1answer
298 views

Idiomatic Scala translation of Kiselyov's zippers?

Oleg Kiselyov showed how to make a zipper from any traversable by using delimited continuations. His Haskell code is quite short: module ZipperTraversable where import qualified Data.Traversable ...
6
votes
1answer
194 views

example uses scalaz.Lens's modf, modp and xmap

There are number of great tutorials and posts out there covering the more straightforward of Lens's methods, e.g. Cleaner way to update nested structures; can anyone provide example uses for these ...
4
votes
0answers
105 views

Does Scala continuation plugin support nested shift?

I am going through the following Shift/Reset tutorial: http://www.is.ocha.ac.jp/~asai/cw2011tutorial/main-e.pdf. I got pretty good results so far in translating the OchaCaml examples to Scala (all ...
22
votes
1answer
1k views

Are there any documented anti-patterns for functional programming? [closed]

Next month I'm going to work on a new R&D project that will adopt a functional programming language (I voted for Haskell, but right now F# got more consensus). Now, I've played with such ...
4
votes
2answers
139 views

Port Haskell code using Control.Parallel to Scala

The Haskell code below uses par and pseq to do some multicore number-crunching as a toy to show several cores being used. What would be the easiest and most idiomatic way to express this in Scala? ...
13
votes
1answer
271 views

Haskell equivalent of scala collect

I'm trying to read in a file containing key/value pairs of the form: #A comment a=foo b=bar c=baz Some other stuff With various other lines, as suggested. This wants to go into a map that I can ...
14
votes
5answers
467 views

Haskell equivalent to Scala's groupBy

Scala has a function groupBy on lists that accepts a function for extracting keys from list items, and returns another list where the items are tuples consisting of the key and the list of items ...

1 2 3 4 5 9
15 30 50 per page