A functional programming language

learn more… | top users | synonyms

3
votes
2answers
119 views

How to use a strong type system to model business constraints?

Following up on my ambiguous question, here's a question that is probably more focused. Consider the following code snippet form a Haskell program: data NightWatchCommand = InvalidCommand | ...
4
votes
3answers
2k views

Lambda expressions with no parameters in Haskell and / or lambda calculus

In eager languages like Scheme and Python, you can use a lambda expression without parameters to delay evaluation, e.g. in Scheme (Chicken Scheme): #;1> (define (make-thunk x) (lambda () (+ x 1))) ...
2
votes
2answers
127 views

What is the equivalent of The Little Lisper project in Haskell?

In the book The Little Lisper, you implement a minimal Scheme in 10 Chapters that is capable of interpreting any chapter in the book. To me it seems you could do the same for a 'minimal subset of a ...
0
votes
0answers
52 views

Chronological/evolutionary positioning of Curry in relation to Haskell and Prolog

is Curry a transitional language from FP to Logic Programming (Haskell to Prolog), like Scala is a transitional language from imperative to FP (Java to Haskell)? I find it hard to come up with a ...
22
votes
4answers
3k views

Is return-type-(only)-polymorphism in Haskell a good thing?

One thing that I've never quite come to terms with in Haskell is how you can have polymorphic constants and functions whose return type cannot be determined by their input type, like class Foo a ...
1
vote
2answers
191 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, ...
2
votes
2answers
176 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 ...
7
votes
4answers
334 views

Is there a Haskell idiom for trying several functions and stop as soon as one succeeds?

In Haskell, I can use the type a -> Maybe b to model a function that either returns a value of type b, or returns nothing (it fails). If I have types a1, ..., a(n+1) and functions f1, ..., fn, ...
7
votes
6answers
1k views

Does it make sense to use the term “Space Leak” with regard to Java?

EDIT: To clarify, I am not suggesting that leaks don't happen in a managed application. I'm simply pondering about how we talk about them. There are some highly upvoted discussions about memory ...
35
votes
5answers
2k views

“A proof is a program; the formula it proves is a type for the program”

This might be a philosophical kind of question, but I believe that there is an objective answer to it. If you read the wikipedia article about Haskell, you can find the following: The language is ...
21
votes
8answers
3k views

Using a “strong” type system in the real world, say, for large-scale web-apps? [closed]

I know this is a very broad, ambiguous, and possibly philosophical question. To an extent, that the most important keyword in the question - "strong" type system - itself, is ill-defined. So, let me ...
5
votes
4answers
596 views

How does “repeat x = x:repeat x” return a list in Haskell?

This is supposed to return an infinite list of x's. However a list is created using an element, then the operator ':' and then a list. The recursive definition of repeat' x = x:repeat' x seems to ...
8
votes
5answers
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 ...
38
votes
1answer
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
153 views

Haskell: Is it possible to convert a Num to a Float?

I need to be able to convert generic numbers (instances of Num) to a Float. I searched Hoogle for a function with the signature Num n => n -> Float, but I couldn't find any such functions ...
5
votes
3answers
178 views

What is the purpose of wrapped values in Haskell?

I've recently read an article about Functors, Applicatives and Monads in Haskell and it concludes with these statements: functors: you apply a function to a wrapped value using fmap or <$> ...
119
votes
5answers
23k views

What exactly makes the Haskell type system so revered (vs say, Java)?

I'm starting to learn Haskell. I'm very new to it, and I am just reading through a couple of the online books to get my head around its basic constructs. One of the 'memes' that people familiar with ...
80
votes
13answers
45k views

Is Haskell worth learning? [closed]

I am looking at this question primarily from a career point of view, so I hope you answer it accordingly. I am fairly proficient with Python, can write C++ and I am a final year student of computer ...
62
votes
2answers
10k views

What is the “Free Monad + Interpreter” pattern?

I've seen people talking about Free Monad with Interpreter, particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement ...
14
votes
2answers
690 views

Is it possible to “bake dimension into a type” in haskell?

Suppose I want to write a library that deals with vectors and matrices. Is it possible to bake the dimensions into the types, so that operations of incompatible dimensions generate an error at compile ...
40
votes
7answers
6k views

How do you encode Algebraic Data Types in a C#- or Java-like language?

There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as: data ConsList a = Empty | ConsCell a (ConsList a) consmap f ...
4
votes
2answers
333 views

Is there any practical use for the empty type in Common Lisp?

The Common Lisp spec states that nil is the name of the empty type, but I've never found any situation in Common Lisp where I felt like the empty type was useful/necessary. Is it there just for ...
5
votes
3answers
2k views

What is this algorithm for converting strings into numbers called?

I've been doing some work in Parsec recently, and for my toy language I wanted multi-based fractional numbers to be expressible. After digging around in Parsec's source a bit, I found their ...
9
votes
2answers
493 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 ...
6
votes
3answers
174 views

Why don't “multi-infinite” list comprehensions work with lazy evaluation?

As a simple demonstration of the efficiency of Haskell style, I thoughtlessly ran the following: take 100 [(a, b, c) | a <- [1..], b <- [1..], c <- [1..], a^2 + b^2 == c^2] This should be a ...
9
votes
2answers
2k views

Why is the Scala Option type not called Maybe, just as in Haskell? [closed]

Why is the Scala Option type not called Maybe, just as in Haskell? Maybe makes a lot more "semantic sense" to me, but maybe Option has different behaviour I am not aware of. Is there any particular ...
4
votes
1answer
70 views

Performance of list concatenation followed by scanning

Consider the following code snippet: -- list_1 = [1, 2, 3] -- list_2 = [4, 5, 6] final_list = list_1 ++ list_2 result = map (+1) final_list Is the time spent by it proportional just to the length ...
23
votes
3answers
13k views

Haskell vs Erlang for web services

I am looking to start an experimental project using a functional language and am trying to decide beween Erlang and Haskell, and both have some points that I really like. I like Haskell's strong ...
16
votes
1answer
450 views

Haskell build and artifact environment similar to Maven

I used to be a Java developer for a long time, but recently, I joined a Haskell team. In the java world, if you have a large project, with several teams working on it, a common approach is to use an ...
3
votes
1answer
197 views

How to manage the state in a GUI app with Haskell

I am using wxHaskell to create a simple GUI that has typical components like Buttons, Panels, etc. When some of these components perform an action (like callback), the generic status of the ...
0
votes
1answer
97 views

The use of '#'-sign in haskell program text

What do those #-signs mean? For example, data Word = W# Word# deriving (Eq, Ord) I tried to google it but I found nothing.
0
votes
0answers
85 views

Haskell + OpenGL framework

I'm writing a framework in Haskell where I'd like to use OpenGL to draw lines, shapes... I'm encountering a problem defining the structure of my program. I have for example a Polyline type which holds ...
1
vote
1answer
81 views

how do interpreters differ for statically- or dynamically-typed languages?

Writing an interpreter for a dynamically typed language usually involves creating an Environment, a data structure which stores mappings of variable names to their values. Values are boxed in some ...
16
votes
3answers
901 views

Why isn't there a typeclass for functions?

In a learning problem I've been messing around with, I realised I needed a typeclass for functions with operations for applying, composing etc. Reasons... It can be convenient to treat a ...
8
votes
2answers
256 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 ...
14
votes
2answers
1k views

What is Banana split and fusion in functional programming?

These terms got mentioned in my university course. Quick googling pointed me to some university papers, but I am looking for a simple explanation.
61
votes
5answers
8k views

What can Haskell's type system do that Java's can't and vice versa? [closed]

I was talking to a friend about the differences between the type systems of Haskell and Java. He asked me what Haskell's could do that Java's couldn't, and I realized that I didn't know. After ...
6
votes
5answers
1k views

Why doesn't Haskell have a 'format' function for string interpolation?

I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about Text.Printf — it's not what I'm looking for. The ...
16
votes
3answers
3k views

Ur/Web new purely functional language for web programming? [closed]

I came across the Ur/Web project during my search for web frameworks for Haskell-like languages. It looks like a very interesting project done by one person. Basically, it is a domain-specific purely ...
4
votes
2answers
139 views

Functional Programming - Functions defining specific evaluation of functions passed to it for optimization

Firstmost, I am just getting started with functional programming so I would appreciate corrections in any terminology I may have used incorrectly. Story time, While doing a Project Euler Problem 1 in ...
13
votes
5answers
881 views

Can *any* program task be expressed without state?

This is a theoretical question, but after many years of programming in what I now realize is "normal" imperative technique, using C++ mainly, I've discovered this other world of functional ...
31
votes
7answers
4k views

Is Haskell's type system an obstacle to understanding functional programming? [closed]

I'm studying Haskell for the purpose of understanding functional programming, with the expectation that I'll apply the insight that I gain in other languages (Groovy, Python, JavaScript mainly.) I ...
33
votes
11answers
13k views

Scheme vs Haskell for an Introduction to Functional Programming?

I am comfortable with programming in C and C#, and will explore C++ in the future. I may be interested in exploring functional programming as a different programming paradigm. I am doing this for fun, ...
13
votes
1answer
235 views

Why is Haskell unable to avoid repeated evaluation without the monomorphism restriction?

I just finished learnyouahaskell the other day, and I was trying to make sense of the Monomorphism Restriction, as described by the Haskell Wiki. I think I understand how the MR can prevent repeated ...
10
votes
1answer
392 views

Composability Example of Software Transactional Memory

One of the major advantages of software transactional memory that always gets mentioned is composability and modularity. Different fragments can be combined to produce larger components. In ...
3
votes
2answers
276 views

Why are the types in Java considered less 'strong' than haskell?

I asked this question a while ago - the answers were really helpful, and as I read them and the questions that were linked - I also saw this, and the first answer I think really addresses what I ...
35
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 ...
0
votes
2answers
203 views

Missing `$` like operators in Haskell

Below I've produced what I believe to be a summary of the standard $ like operators for various classes in Haskell. There's some gaps however. Following the applicative pattern, you would think those ...
4
votes
3answers
3k views

Why C# is not statically typed but F# and Haskell are?

There was a talk given by Brian Hurt about advantages and disadvantages of static typing. Brian said that by static typing he don't mean C#, but F# and Haskell. Is it because of dynamic keyword added ...
3
votes
2answers
758 views

What is the logic behind the use of different arrows (-> <-) in Haskell?

I've been thinking about language design lately, and reading over some of the new things in Haskell (always a nice source of inspiration). I'm struck by the many odd uses of the left <- and right ...