Questions tagged [functional-programming]

Functional programming is a programming paradigm which primarily uses functions as means for building abstractions and expressing computations that comprise a computer program.

388 questions
24
votes
2 answers

Is computation expression the same as monad?

I'm still learning functional programming (with f#) and I recently started reading about computation expressions. I still don't fully understand the concept and one thing that keeps me unsure when reading all the articles regarding monads (most of…
17
votes
1 answer

No Naive Set Theoretic Models of Polymorphic Lambda Calculus?

In Philip Wadler's paper on Theorems for Free he states in Section 2 on Parametricity that there are no naive set-theoretic models of polymorphic lambda calculus In the naive set-theoretic model types are sets and functions are set-theoretic…
user30564
8
votes
2 answers

Total functional programming language without an static type checker

All papers with the subject of total functional programming make use of some kind of static type checking to ensure totality. This make sense considering hoy easily is to make a language Turing-complete. The question is: Is there any…
user3368561
  • 485
  • 3
  • 9
6
votes
1 answer

Can we express the program to find last element of a list as a catamorphism?

So I've got a bit of category theory under my belt, and I am reading a few papers about calculating functional programs. I've expressed programs like summing a list as a catamorphism, and I've fused some catamorphisms, too. I thought it might be…
Adam
  • 95
  • 4
6
votes
1 answer

Is Equational Reasoning an application of Referential Transparency?

In various discussions of the merits of functional programming, the phrase referential transparency or equational reasoning is often listed. My question is - are these roughly the same thing? (One being the concept, and the second being the process…
hawkeye
  • 1,199
  • 8
  • 20
6
votes
4 answers

Is there difference between a function in mathematics to a function in computer science?

I never learned a lot of mathematics (generally only arithmetic) and never learned computer science in a formal frame. I emphasize that I don't mean to ask about a "function" in programming ("procedure"/"method"), rather only about the difference…
guesto
  • 63
  • 3
6
votes
2 answers

Representing partialled/curried functions in postfix notation?

I'm working on a small query language in JSON. A query consists of a JSON array of JSON elements, such as strings, numbers, booleans, etc. Strings starting with a '$' or '@' represent postfix unary or binary operators, respectively. I want to…
Mark LeMoine
  • 173
  • 5
4
votes
2 answers

Is there a universal identity or zero value for folding?

I'm using Haskell notation for illustration, hopefully it is known widely enough for this to make sense. In the following fold function the second argument is what I'm calling the identity: foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b It…
dukereg
  • 295
  • 1
  • 3
4
votes
0 answers

Monad with a partial inverse, but not a comonad

I have encountered a structure that looks like a monad with a one-sided inverse and some additional properties. I am not sure which properties of this structure are essential and which are accidental, so I will follow a simple example in my…
AndreA
  • 141
  • 1
3
votes
2 answers

Occurrences notation in "Compiling Pattern Matching to Good Decision Trees"

From Compiling Pattern Matching to Good Decision Trees (Luc Maranget, Proceedings of ML '08, pp. 35–46. ACM, 2008.) We also consider the usual occurrences. Occurrences are sequences of integers that describe the positions of subterms. More…
qed
  • 223
  • 1
  • 6
3
votes
1 answer

Difference between function, method, routine, procedure, subprogram, subroutine, block, task

I don't know if I should have posted this on StackOverflow or here but what's the difference between these terms? Are the definitions of these dependent on the programming languages or they're things independent of them?
Emad
  • 411
  • 3
  • 10
3
votes
1 answer

Pattern matching on function application

Suppose we have a function f :: a -> b and a function g :: b -> a such that f . g = id. You might say that g is the "inverse" of f (and vice versa). Could we then pattern match on something like f x on the left hand side by replacing occurences of x…
malte-v
  • 155
  • 4
3
votes
1 answer

Intuition for “run” function of monads

I'm learning about monads, I understood why they are useful, I understood in general what bind, join, return do. I also looked at basic usage examples for the basic reader / writer / state / list / maybe monads. Still, being a beginner, I still…
jack malkovick
  • 251
  • 2
  • 9
2
votes
2 answers

General term for map/fmap

The general term for folds is a catamorphism. The general term for unfold is an Anamorphism. Is there an equivalent term for map? I know that a map is a type of fold however restriction is significant. Also it would be useful to have an…
2
votes
3 answers

Proving monad laws for flatMap and unit, given laws for compose and unit

I'll use scala notation but hopefully things will make sense in general (I'm trying to prove that you can define a monad using either [flatMap (aka bind) and unit] or [compose and unit]) The book Functional Programming in Scala (github at…
1
2 3