Functional programming is a paradigm which attempts to solve computational problems by the chained evaluation of functions whose output is determined by their inputs rather than the programme state. In this style of programming, side effects and mutable data are deprecated and usually strictly ...

learn more… | top users | synonyms (1)

0
votes
2answers
78 views

How do you deal with a mutable buffer in a functional space?

I have a stream parsing method in C# that reads portions of a protocol frame from the STOMP protocol; the specification isn't the important part for the question though. What is important is that I ...
1
vote
1answer
77 views

Functional Programming in PHP

Modern PHP is mostly written Object Oriented. Other than the fact that there is inertia towards the Object Oriented in the PHP community, is there anything about the language itself that would make it ...
15
votes
6answers
4k views

A language based on limiting amount of arguments passed to functions

The idea is inspired by the fact operators such as +, -,%, etc. can be seen as functions with either one or two arguments passed, and no side-effects. Assuming I, or someone else, writes a language ...
15
votes
9answers
2k views

What would be good factual arguments to convince high level management to consider functional programming? [closed]

There are tons of "theoretical" arguments for why functional programming is a Good idea (too many for that to have stayed as an open question, and correctly so). However, most of them are arguments ...
5
votes
1answer
242 views

How to move from OOP object composition to FP function composition in C#

I have been working for a few weeks on a new web project and I am realizing that all I am doing is basically calculations and transformations on data, and that most of my classes do not contain any ...
3
votes
1answer
76 views

Why don't more functional languages / tools feature case-split and expression search? [closed]

I was blown away by a recent presentation on the Idris language. One thing that looks particularly powerful is its case-split and expression (proof) search features that you can use in the IDE/REPL to ...
2
votes
1answer
104 views

Are promises functional

Functional programming is often explained to agree with lazy evaluation. As far as I know lazy evaluation means that a method gets called if the evaluator/browser/etc. thinks that is the next best ...
7
votes
2answers
248 views

What is a Comonad and how are they useful?

Recently I've been dusting off my knowledge on how Monads work. I've also been introduced to the concept of a 'Comonad', which is described as the inverse of a monad. However, I am impossible to wrap ...
18
votes
3answers
3k views

Equivalent of SOLID principles for functional programming

I've found the SOLID principles quite useful when thinking about object-oriented design. Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?
7
votes
5answers
1k views

What makes functional programming languages declarative as opposed to Imperative?

On many articles, describing the benefits of functional programming, I have seen functional programming languages, such as Haskell, ML, Scala or Clojure, referred to as "declarative languages" ...
7
votes
2answers
159 views

Data structure for two-dimensional board games in Functional languages

I am creating a simple MiniMax implementation in the functional programming language Elixir. Because there are many perfect-knowledge games (tic tac toe, connect-four, checkers, chess, etc), this ...
0
votes
2answers
110 views

Advantages of workflow based software development vs normal programming based software development

I am very new to workflows, and trying to understand why workflows are used. While surfing internet, I haven't found any strong point for using workflows. Please explain me the scenarios where ...
6
votes
0answers
223 views

What lambda function optimizations, if any, are planned for Java 9 and beyond?

I'm working on a high-performance project where Java 8's lambda functions are enormously useful. I've found, however, that they're memory inefficient when used en masse. For example, suppose I need to ...
2
votes
1answer
92 views

Programatically determine that some functions are pure

I saw this question that shows it is impossible to programatically determine if a javascript function is pure, but is it sometimes possible to affirm that a function is pure - so something like... ...
4
votes
0answers
97 views

Does it make sense to apply the principles in Redux to OO languages?

Redux is essentially functional programming, and it makes a lot of sense. As I move back to a non-javascript OOP language in a different project I would like to apply the same principles such as ...
27
votes
3answers
5k views

What is referential transparency?

I have seen that in imperative paradigms f(x)+f(x) might not be the same as: 2*f(x) But in a functional paradigm it should be the same. I have tried to implement both cases in Python and Scheme, ...
6
votes
3answers
935 views

How Does The Maybe Monad Relate To The Option Type?

I was doing a presentation on F# and was discussing the Option type when someone in the audience asked me if the Option type is F#'s implementation of the maybe monad. I know that's not the case but ...
5
votes
0answers
73 views

How does the Free monad and Reactive Extensions correlate?

I come from a C# background, where LINQ evolved into Rx.NET, but always had some interest in FP. After some introduction to monads and some side-projects in F#, I was ready to try and step to the next ...
1
vote
2answers
42 views

Type of map for Try[T]

I was looking at the type of map for Try[T] in Scala, which is: def map[S](f: T=>S): Try[S] From Haskell, I am used to the type of map being: map :: (a->b)->[a]->[b] This seems very ...
3
votes
2answers
135 views

Referential Transparency by using Zero References?

Referential Transparency is one of the corner stones of functional programming that allows us to apply equative reasoning to our code. However it does so at a cost to performance, by use of immutable ...
14
votes
5answers
414 views

Is it still valid to speak about anemic model in the context of functional programming?

Most of DDD tactical design patterns belong to object-oriented paradigm, and anemic model describes the situation when all business logic is put into services rather than objects thus making them a ...
4
votes
2answers
92 views

Under what scenarios would 'functional' `Try` objects be more or less beneficial than 'rx' `Try` objects?

Definitions used by this question: 'functional' Try is what https://github.com/lambdista/try is. Success and Failure are subclasses of Try. Exceptions aren't thrown by the called function. 'rx' Try ...
51
votes
12answers
9k views

Why isn't functional programming more popular in the industry? Does it catch on now? [closed]

During my four years at university we have been using much functional programming in several functional programming languages. But I have also used much object oriented programming to, and in fact I ...
2
votes
2answers
578 views

Why isn't functional programming embraced more widely? [duplicate]

Possible Duplicate: Why isn't functional programming more popular in the industry? Does it catch on now? I've been working as a J2EE developer for the past 3 years and wanted to learn ...
5
votes
4answers
787 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
40
votes
10answers
7k views

Why would a program use a closure?

After reading many posts explaining closures here I'm still missing a key concept: Why write a closure? What specific task would a programmer be performing that might be best served by a closure? ...
0
votes
2answers
143 views

Almost point-free style

Programmers often talk about point-free style. In contrast to the imperative style (pseudocode): h := function(x) { y := f(x) z := g(y) return z; } one might write the following point-free: ...
16
votes
2answers
2k views

Does Clojure have continuations/coroutines/etc?

I started programming with Python, and I was really confused by concepts like coroutines and closures. Now I think I know them on some superficial level, but I've never felt that "enlightement" ...
2
votes
1answer
69 views

Term for the opposite of the functional Compose operator

In functional programming, given a function f and a function g we can define a function . (compose): let (.) f g = fun x -> g (f x) Is there a term for the function which applies arguments in the ...
34
votes
7answers
4k views

What do you call a function that's pure, meaning the same input will always return the same output, but also has side effects?

Say we have a normal pure function such as function add(a, b) { return a + b } And then we alter it such that it has a side effect function add(a, b) { writeToDatabase(Math.random()) return ...
26
votes
1answer
1k views

How to implement a branch-and-bound in a functional programming language?

I am trying to write a branch and bound search on the set of all functions f: D -> R, where the domain size is small (|D| ~ 20) and the range is much bigger (|R| ~ 2^20). Initially, I came up with the ...
2
votes
6answers
242 views

How does immutability remove the need for locks when two threads are trying to update the shared state?

Okay so I read through this: Does immutability entirely eliminate the need for locks in multi-processor programming? And this was the main takeaway for me: Now, what does it get you? ...
44
votes
13answers
11k views

Why are side-effects considered evil in functional programming?

I feel that side effects are a natural phenomenon. But it is something like taboo in functional languages. What are the reasons? My question is specific to functional programming style. Not all ...
5
votes
2answers
121 views

Using queues to decouple functions/avoid direct calling?

Kind of a functional programming newbie question here: I've been reading the transcripts of some of Rich Hickey's talks, and in several of his more well-known ones, he recommends using queues as an ...
2
votes
4answers
511 views

What is Big-O notation for purely functional languages?

Is it still relevant? Instead of var result = new List<int>(); for (var i = 0; i < prev.Count; ++i) { result.Add(prev[i] * 2); } where the result.Add, prev[i], and * 2 instructions ...
57
votes
4answers
7k views

Is functional programming faster in multithreading because I write things differently or because things are compiled differently?

I'm diving into the world of functional programming and I keep reading everywhere that functional languages are better for multithreading/multicore programs. I understand how functional languages do a ...
5
votes
2answers
125 views

What is the difference between explicit parameters and closures

In F#, a tail recursive List.filter function can be implemented like: let filter f = let rec filterImpl f acc = function | [] -> List.rev acc | h :: t -> filterImpl f (if ...
51
votes
3answers
7k views

What are the biggest differences between F# and Scala?

F# and Scala are both functional programming langugages that don't force the developer to only use immutable datatypes. They both have support for objects, can use libraries written in other languages ...
1
vote
2answers
232 views

Need help with deciding elements for icon creating application

I'm trying to practice programing by creating a simple application which, I think, I can manage to do in .Net C# in Visual Studio 2010. I'm working on simple application which will let me to create ...
8
votes
2answers
303 views

How to handle complex calculated fields in an ORM

In our API we've got a few central datatypes which need to be "decorated" (so to speak) after retrieval from the database with calculated values. The database is accessed through an ORM which follows ...
1
vote
3answers
126 views

Logic Programming(Unification) vs List Comprehensions (in Functional Programming)

I found this answer on StackOverflow very clear to explain the difference beween the Logic Programming paradigm and the Functional Programming paradigm: The thing that makes logical append ...
7
votes
6answers
2k views

A programming language that does not allow IO. Haskell is not a pure language

Are there any 100% pure languages (as I describe in the Stack Overflow post) out there already and if so, could they feasibly be used to actually do stuff? i.e. do they have an implementation? I'm not ...
36
votes
7answers
15k views

Haskell AND Lisp vs. Haskell OR Lisp [closed]

I currently code with C, C++, and Python. I'm wanting to pick up a functional programming language, and right now I'm leaning toward Haskell. I do NOT want to start a "Haskell vs Lisp" war here; what ...
4
votes
1answer
190 views

JavaScript functional conversion from flat list to tree

I've been going through the RxJS tutorials http://reactivex.io/learnrx/. Almost all of the exercises involve moving from a hierarchical structure to a flat structure so I thought I'd try to do the ...
5
votes
3answers
216 views

Should databases be viewed as Monads?

Because any kind of persistence updates/inserts/deletes represents in some sense a kind of state change in a database, it makes me wonder whether databases can be considered monads. We say the same ...
2
votes
3answers
100 views

Declarative programming for deterministic real time control

Let's say you want control a motor in real time. Normally you would use a microcontroller or PC with e.g. c-programming language. So you would use an imperative approach. You tell the microcontroller ...
3
votes
1answer
95 views

Can I use maybe on multiple inputs in Haskell?

Suppose I wanted to test that both my inputs are positive. Can I do something like this? test :: Float -> Float -> Maybe Float Float test a b | a>0 && b>0 = a b | ...
7
votes
3answers
1k views

Is a function getting a value from another function considered pure?

I'm trying to figure out a way to handle default variable values when making functions without side effects and have ended up with the following: function getDefaultSeparator() { return ':'; } ...
40
votes
2answers
4k views

Why (or why not) are existential types considered bad practice in functional programming?

What are some techniques I might use to consistently refactor code removing the reliance on existential types? Typically these are used to disqualify undesired constructions of your type as well as to ...
3
votes
2answers
288 views

Shared data in functional programming

I have been working on a project in JavaScript which requires a data structure (read only), to be shared between two functions. var mySharedData = ['hours', 'minutes', 'seconds']; Now I have two ...