A functional programming language

learn more… | top users | synonyms

1
vote
4answers
68 views

What's the proper way of dealing with a global file path?

I don't have compilable code, because the code in question depends on a large function that's irrelevant to the question, but say I have the following scenario: savePath = "C:\\..." changePath1, ...
1
vote
2answers
247 views

How bad is using underscore in names? [on hold]

I am mainly a C programmer. In my world, writing likeThis or like_this is just a matter of style. In Haskell however, it seems that camelCase is the definite choice. Personally, I find the later much ...
3
votes
1answer
161 views

Why does Haskell's built in max function run faster than mine?

I noticed that for some reason, Haskell's built in max function (which returns the greatest of two numbers) runs much faster than the one I wrote, even though they are essentially identical. From ...
1
vote
1answer
133 views

Is Haskell appropriate for Signal Processing, Communication Systems and Information Theory?

I have been working on Software-Defined Radio projects for almost a year. This is an area which requires lots of signal processing (digital filters and FFTs), communication theory (modulation, ...
4
votes
1answer
258 views

Who invented Haskell's type classes?

Haskell's type classes are a very powerful tool and give Haskell a great expressive ability, compared to functional languages that don't have them. When were they invented, and who invented them?
7
votes
1answer
291 views

Relation between objects

For a few weeks I’ve been thinking about relation between objects – not especially OOP’s objects. For instance in C++, we’re used to representing that by layering pointers or container of pointers in ...
10
votes
2answers
474 views

In-memory datastore in Haskell

I want to implement an in-memory datastore for a web service in Haskell. I want to run transactions in the STM monad. When I google hash table steam Haskell I only get this: Data. BTree. HashTable. ...
13
votes
5answers
2k views

In what programming language did “let” first appear?

I was wondering about the origins of the "let" used in Lisp, Clojure, and Haskell. Does anyone know which language it appeared in first?
2
votes
1answer
89 views

Why are data constructors with the same name disallowed in different type constructors?

The following declaration gives an error: type Vec2d = (Float, Float) type Vec3d = (Float, Float, Float) -- Rect x y defines a rectangle spanning from (0,0) to (x,y) data Obj2d = Rect Float Float ...
0
votes
3answers
108 views

Are functional languages a kind of program derivation?

Program derivation is defined as the derivation of a program from it's specifications. Usually this specification language is some form of propositional logic, but from what I understand, it need not ...
9
votes
1answer
1k views

I feel something uncomfortable with Haskell record syntax

Most of Haskell syntax has beauty of purity. But the record syntax looks ugly. It's uncomfortable. It feels some kind of mixture with C. It requires comma and braces. Haskell has tab,line based ...
4
votes
1answer
350 views

Is there an imperative language with a Haskell-like type system? [closed]

I've tried to learn Haskell a few times over the last few years, and, maybe because I know mainly scripting languages, the functional-ness of it has always bothered me (monads seem like a huge mess ...
1
vote
3answers
2k views

Using foldr to append two lists together (Haskell)

I have been given the following question as part of a college assignment. Due to the module being very short, we are using only a subset of Haskell, without any of the syntactic sugar or idiomatic ...
39
votes
2answers
4k 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 ...
29
votes
2answers
2k views

Why did the Haskell committee choose monads to represent I/O?

The Clean language uses uniqueness types to handle I/O in a purely functional setting. Why did the Haskell committee go with monads instead? Were there other proposals for handling state that the ...
3
votes
2answers
189 views

Why isn't Haskell able to optimize infinite lists?

Lets say you've got a list l = [0, 2..] and you want to get the nth number when n is pretty large, say n=123456789. So you call l !! 123456789. On my machine, this results in out of memory. So why ...
15
votes
2answers
1k views

Why does Haskell have built-in “if/then/else” instead of defining it as a simple library function?

Why does Haskell have a built-in if/then/else, which is dependent on the Bool type, instead of having a simple library function? Such as if :: Bool -> a -> a -> a if True x _ = x if False _ ...
6
votes
2answers
143 views

Guidelines for returning collections from public functions

The Problem Imagine you have a function in a public API that needs to return some kind of collection. Its type is something like foo :: a -> b where b is some kind of collection. As far as I ...
2
votes
1answer
113 views

To which level Haskell's HDBC is lazy?

The HDBC documentation states: fetchAllRows :: Statement -> IO [[SqlValue]]Source Lazily fetch all rows from an executed Statement. You can think of this as hGetContents applied to a ...
2
votes
1answer
142 views

Picking a card from a shuffled deck

I'm pretty new to Haskell although I did some ML many moons ago. I'm trying to set up a deck of playing cards, shuffle them and then deal them. I have the deck and shuffle sorted (of a fashion) but ...
4
votes
2answers
254 views

Better way to familiarize myself with Haskell [closed]

I'm a Haskell beginner. I started learning Haskell around 20-25 days back. With a programming day job I am doing this in my spare time because I wanted to learn about functional programming. ...
25
votes
0answers
2k 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 ...
1
vote
1answer
179 views

What is this programming style? “Monoid-ic”?

In a moderately old blog post, Conal Elliot makes an interesting (if less than serious) argument that C is a purely functional language, by drawing a parallel between the combination of the C ...
4
votes
2answers
476 views

Implement Haskell typeclass with C# interface

I'm trying to compare Haskell's type classes and C#'s interfaces. Suppose there is a Functor. Haskell: class Functor f where fmap :: (a -> b) -> f a -> f b How to implement this type ...
14
votes
4answers
1k views

How does persistence fit into a purely functional language?

How does the pattern of using command handlers to deal with persistence fit into a purely functional language, where we want to make IO-related code as thin as possible? When implementing ...
1
vote
2answers
160 views

Why does a monad use “return” or “unit” rather than “lift”?

This is partly genuine curiosity, and partly a check on my understanding. I'm probably missing the point. In Haskell, why does a monad use operations called return or unit to describe putting a type ...
15
votes
6answers
614 views

Introducing functional programming into your development environment [closed]

This is a long story but I will try to summarize it as best I can. We are a .NET shop that writes software for a variety of different types of funds. For example, we write health claims management ...
8
votes
6answers
1k views
30
votes
2answers
2k views

Misconceptions about purely functional languages?

I often encounter the following statements / arguments: Pure functional programming languages do not allow side effects (and are therefore of little use in practice because any useful program does ...
23
votes
6answers
2k 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 ...
1
vote
2answers
100 views

Mapping a list of optional values to an optional list of values

I have encountered the following pattern while programming in Haskell (but the pattern could occur in any language supporting lists, option types, and mapping of a function over a list). I have types ...
5
votes
4answers
510 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 ...
20
votes
3answers
1k views

Different ways to see a monad

While learning Haskell I have faced a lot of tutorials trying to explain what are monads and why monads are important in Haskell. Each of them used analogies so it would be easier to catch the ...
27
votes
11answers
8k 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, ...
3
votes
2answers
371 views

Is there any particular reason for the use of lists over queues in functional programming languages?

Most functional programming languages such as Scheme and Haskell use lists as their main data structure. Queues are identical to lists, except for the fact appending to the end - not to the begin - ...
1
vote
1answer
130 views

Building proprietary software over haskell compiler [closed]

Is it perfectly legal to use GHC as base and build some commercial application over its top ? Are there such examples I can can interact with ?
7
votes
6answers
661 views

Challenges for the experienced coder to learn functional programming? [closed]

What are the challenges that an experienced programmer with the usual C++/UNIX background would face when trying to learn functional programming? The main motive for learning is to gain a fresh ...
4
votes
2answers
223 views

Can someone explain the concept behind Haskell's memoization?

(note I'm putting the question here because it's about the conceptual mechanics of it, rather than a coding problem) I was working on a small program, that was using a sequence of fibonacci numbers ...
10
votes
2answers
383 views

Are types erased in Haskell?

Haskell has a notion of “generic functions” that has some apparent similarity with common lisp—having neither experience with Haskell nor with common lisp, I might be very approximative here. This ...
9
votes
1answer
406 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 ...
15
votes
2answers
388 views

Side effect-free interface on top of a stateful library

In an interview with John Hughes where he talks about Erlang and Haskell, he has the following to say about using stateful libraries in Erlang: If I want to use a stateful library, I usually build ...
0
votes
1answer
167 views

Haskell: Best tools to validate textual input?

In Haskell, there are a few different options to "parsing text". I know of Alex & Happy, Parsec and Attoparsec. Probably some others. I'd like to put together a library where the user can input ...
18
votes
2answers
854 views

Type checking and recursive types (Writing the Y combinator in Haskell/Ocaml)

When explaining the Y combinator in the context of Haskell, it's usually noted that the straight-forward implementation won't type-check in Haskell because of its recursive type. For example, from ...
11
votes
2answers
621 views

Functional programming and stateful algorithms

I'm learning functional programming with Haskell. In the meantime I'm studying Automata theory and as the two seem to fit well together I'm writing a small library to play with automata. Here's the ...
17
votes
3answers
2k 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 ...
4
votes
3answers
1k 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 ...
8
votes
2answers
612 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 ...
5
votes
1answer
506 views

Maths needed to understand theory behind Haskell's type system?

Recently, I've become deeply interested in Haskell. While attempting to learn new concepts (e.g. the forall keyword and ST monad) and Haskell's type system in general, I continually run into ...
45
votes
5answers
5k views

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

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 ...
27
votes
4answers
5k views

Are there any downsides or problems with Haskell?

I'm looking at diving into Haskell for my next (relatively trivial) personal project. The reasons that I'm tackling Haskell are: Get my head into a purely functional language Speed. While I'm sure ...