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
0answers
3 views

Concepts related to higher order functions

I am trying to understand higher order functions. I know that they are functions that can take functions as parameters and return functions as results. But I feel there is more to it, for example, I ...
1
vote
1answer
63 views

Should we ignore object-oriented and study functional? [on hold]

I am programming in Haskell. I was wondering since that Functional programming is so perfect, like codes are more concise lesser complexity makes us think more about how program should work ...
0
votes
1answer
160 views

Non-trivial functions that operate on any monad [closed]

Monads are extremely general, so methods that operate on monads are widely applicable. On the other hand, methods I know of that can apply to any monad tend to be... really, really trivial. Barely ...
0
votes
1answer
67 views

Haskell types for functions

I don't understand the answer to this question: Q: Can Haskell find a type for the function selfapply defined by: selfapply f = f f A: The function selfapply is not typeable in the simple system of ...
21
votes
6answers
3k views

how a pure functional programming language manage without assignment statements?

When reading the famous SICP, I found the authors seem rather reluctant to introduce the assignment statement to Scheme in Chapter 3. I read the text and kind of understand why they feel so. As ...
22
votes
7answers
1k views

Does functional programming ignore the benefits gained from the “On the Criteria To Be Used in Decomposing Systems into Modules” (data hiding)?

There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles ...
-4
votes
0answers
75 views

Does imperative programming have a (mainstream) future? [on hold]

I have written a few small programs in Python and C++ and am currently learning F# (I am already quite familiar with FP concepts, as a result of reading the Learn you some Haskell tutorial until the ...
1
vote
1answer
182 views

What is the “->” symbol called?

I have seen the -> operator/symbol in Java 8 predicates recently and wondered what its name is. I know that it is used in lambda expressions, but I know that the symbol for lambda is λ, so that's ...
2
votes
2answers
92 views

Dealing with states in a immutable approach

I want to know how to deal when you have some states in a program, with functions that depends on them, but with a immutable approach. I read some examples and questions, but all focus in a small ...
0
votes
2answers
669 views

I cannot understand the application of oops How can I develop the understanding of application of oops? [closed]

I am a developer in PHP technology, I am aware of almost all the basics of OOPS, but still cannot find out the way to apply these concepts over a procedural programming. I do it in very orthodox way, ...
0
votes
3answers
105 views

Why python function programming functions are not collection methods? [duplicate]

In other words, is there a Python design related reason for it to be so? Functions like map, filter, reduce etc. are just plain functions. Is it just a poor design choice (if it is a good one, ...
7
votes
0answers
179 views

Maintaining State without assignment

I am learning functional programming and I have trouble understanding how some particular scenarios are implemented without the use of assignment. The following simple problem pretty much sums up my ...
34
votes
7answers
13k 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 ...
7
votes
3answers
4k views

Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO ...
16
votes
1answer
507 views

Using uniqueness types to implement safe parallelism

I've been interested in uniqueness types as an alternative to monads in pure functional languages for some time; unfortunately, this is kind of an esoteric area of CS research and online resources ...
100
votes
15answers
43k views

What is the advantage of currying?

I just learned about currying, and while I think I understand the concept, I'm not seeing any big advantage in using it. As a trivial example I use a function that adds two values (written in ML). ...
2
votes
1answer
370 views

Local Updates in Persistent/Immutable Data Structures

I'm getting into ReactJS and am intrigued but also confused about persistent data structures. I love the idea, but I'm not sure how to take my MV*, Mutable, Observable Bindings experience in designing ...
36
votes
1answer
3k 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 ...
0
votes
1answer
139 views

Advantages of the imperative style over the functional style [duplicate]

There's a lot of hype over functional languages right now, and I've spent the last year studying Haskell as my intro to FP as a result. Seeing the advantages FP provides is easy (such as referential ...
6
votes
1answer
305 views

How to represent hard-to-calculate “properties” of “objects” in functional code?

I have a polyline "class" in my Clojure program, which is represented by a vector of points. (It's not really a class or anything.) The polyline's length (in the geometric sense) is something that is ...
4
votes
1answer
136 views

Pattern matching against two similar types

What is the best way to handle pattern matching in the following situation? sealed trait Metadata final case class Metadata1() extends Metadata final case class Metadata2() extends Metadata final ...
3
votes
2answers
670 views

How is intermediate data organized in MapReduce?

From what I understand, each mapper outputs an intermediate file. The intermediate data (data contained in each intermediate file) is then sorted by key. Then, a reducer is assigned a key by the ...
11
votes
2answers
303 views

Is higher-rank parametric polymorphism useful?

I'm pretty sure everyone is familiar with generic methods of the form: T DoSomething<T>(T item) This function is also called parametrically polymorphic (PP), specifically rank-1 PP. Let's ...
0
votes
0answers
30 views

Accessing intermittently available resources with transactions and post-access cleanup in a generalized, functional, composable way

The following psuedo-code illustrates what I'd like to be able to do. Is there a way to accomplish something like this in Scala?: trait IntermittentlyAvailableResource trait ...
0
votes
1answer
66 views

FP: Capturing the characteristics of a process which blocks, causes side-effects, and may fail

I have a driver function modifyFile that interacts with many sources in the outside world (e.g. HTTP, filesystem). Let's say the code is as such: def downloadFile(from: String, to: String): Try[Unit] ...
17
votes
2answers
889 views

What are the typical applications of Lisp macros?

I am trying to learn some LISP and I have read a lot about the importance of LISP macros so I would like to get some working experience with them. Can you suggest a practical application area that ...
11
votes
3answers
3k views

What is the name of a function that takes no argument and returns nothing? [closed]

In Java 8's java.util.function package, we have: Function: Takes one argument, produces one result. Consumer: Takes one argument, produces nothing. Supplier: Takes no argument, produces one result. ...
6
votes
0answers
140 views

Is it common practice to transform requirement specifications into predicate logic for functional programming?

I've recently been assigned to work on a small project which is being implemented in Haskell. Coming from an OO/imperative background, I'm used to converting requirements/user-stories into use-cases ...
28
votes
2answers
2k views

Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?

In a blog post on F# for fun and profit, it says: In a functional design, it is very important to separate behavior from data. The data types are simple and "dumb". And then separately, you ...
5
votes
3answers
444 views

Is Functional Programming a viable alternative to dependency injection patterns?

I have recently been reading a book entitled Functional Programming in C# and it occurs to me that the immutable and stateless nature of functional programming accomplishes similar outcomes to ...
0
votes
0answers
93 views

What is the relationship between “flux” and pure functional reactive programming?

Flux, as far as I understood, is a technique about dealing with the dataflow of an application unidirectionally, keeping state isolated from the rest of the program in read-only, self-contained ...
40
votes
12answers
4k views

What programming language generates fewest hard-to-find bugs? [closed]

What language, in your opinion, allows the average programmer to output features with the least amount of hard-to-find bugs? This is of course, a very broad question, and I'm interested in very broad ...
2
votes
1answer
77 views

FP and board game state

I wanted to implement the game of Tic Tac Toe using a functional language (in my case, Scala) but I'm unsure how to go about managing the board game state after each player makes their move. I ...
-1
votes
2answers
202 views

Is functional language without runtime written in C possible?

Every functional language that compiles to native code relies on quite big runtime written in C programming language (well at least ones that I know of, for example Haskell, OCaml, Gambit/Chicken ...
1
vote
1answer
115 views

Functional Programming style: How to write functions - explicit currying, implicit currying or lamdas?

So I have been using F# for a while and studying a bit of Haskell on the side and I have realized I could rewrite the exact same function one of three different ways. Either with implicit currying, ...
11
votes
4answers
484 views

Dealing with state problems in functional programming

I've learned how to program primarily from an OOP standpoint (like most of us, I'm sure), but I've spent a lot of time trying to learn how to solve problems the functional way. I have a good grasp on ...
-1
votes
1answer
67 views

Significance of '__name__ ' attribute in python

1) Below python code, >>> def f(): return creates a function type object which has __name__ attribute with value 'f' which looks fine. But, 2) Below line of code, >>> x = ...
5
votes
3answers
790 views

Can “higher order function” feature allow/maintain abstraction and encapsulation?

Below is the function repeat written using a functional paradigm, such that when called as repeat(square, 2)(5) it will apply the square function 2 times on the number 5, something like ...
1
vote
0answers
88 views

How and where to make global function file in jsp sevlet web application

I am making a website in Servlet&JSP. I am looking for good way to make a specific function file from where I can call and declare my common functions. If I made a java file function. Java, so is ...
-4
votes
4answers
129 views

Does this python program obey functional paradigm?

Below is the hailstone sequence program considering the rule of thumb in functional programming. The simple rule of thumb is: if you can replace any expression, sub-expression or subroutine call ...
24
votes
3answers
2k 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, ...
4
votes
1answer
106 views

How would I isolate changes to mutable state if I need to run two queries to get the final result?

I'm working on some code that takes search criteria from a Rest API and uses it to query a remote API to return results. As an exercise, I wanted to try to separate all state changes to one place, as ...
1
vote
1answer
117 views

How do I enforce 'referential transparency' in this program?

Below is the python program written to follow the rule of thumb in functional programming. The simple rule of thumb is: if you can replace any expression, sub-expression or subroutine call with ...
0
votes
1answer
100 views

Abstracted better? Data driven string creation

I am trying to post this question neutral of programming language so it helps the widest audience. But for those who must know, I am using Objective-C and iOS frameworks. The background: I have a ...
16
votes
6answers
1k views

Does functional programming increase the 'representational gap' between problems and solutions? [closed]

Since machine language (e.g., 0110101000110101) computer languages have generally evolved to higher forms of abstraction, generally making it easier to understand the code when it's applied to a ...
0
votes
1answer
55 views

Dealing with error in data - Idempotent approach

A prior question had an answer that interested me from a design perspective. I work in geospatial data and occasionally have to deal with voids when I read these binary files into my product. What is ...
0
votes
1answer
52 views

Choose approaches for updating an object

Say I have a simple object created by from user input: var input = { url: 'http://example.com/', path: 'abc', user: 'adam' }; And I am to write function(s) that update url and path properties ...
2
votes
1answer
97 views

How to make an interpreter for a stack of Free Monad Transformers

I like the idea of using Free monads to "purify" code and I've used it in some simple scenarios. However, I can't seem to figure out how to write an interpreter for a Free monad transformer. In ...
2
votes
1answer
106 views

Expected time for lazy evaluation with nested functions?

A colleague and I are doing a free R course, although I believe this is a more general lazy evaluation issue, and have found a scenario that we have discussed briefly and I'd like to find out the ...
6
votes
1answer
161 views

Is the use of DSLs in a state monad a good approach to building complex stateful computations?

First, sorry if that title makes no sense. I am a little out of my depth here with the terminology. So, imagine that I'm writing a text editor in Haskell. For the purposes of this question, let's ...