For instance, if I start learning Haskell, what can I find myself using it for. What are some common uses for this language that I hear is a functional one?

32 upvote
  flag
No, I won't because it's a clear cut answer. No wiggle room for opinions and such. I just want to know what the language was created for. – Sergio Tapia
6 upvote
  flag
10 upvote
  flag
@Papuccino1, wait, do you want to know what it's useful for, or what it was created for? The former is what the question is asking, and there's a lot of room for opinion there... – bdonlan
3 upvote
  flag
@Papuccino1 - What benefit do the extra words in your title bring to the question? Also, I think you're misunderstanding the use of the term "functional" in this context, but it's hard to tell. – Chris Lutz
upvote
  flag
Agree on the dupe, though the titles of both questions make them look Subjective & Argumentative. I'm not sure it's a good idea to edit the title of a 6-month-old question though. – finnw
2 upvote
  flag
According to their own website many companies use it for different kinds of purposes... haskell.org/haskellwiki/Haskell_in_industry – Julian
upvote
  flag
Because it's turing complete, anything! Just because it's functional doesn't mean it can't do things! – AJFarmar
upvote
  flag
This document gives a good overview of the strong and weak points of the Haskell ecosystem. – sjakobi

10 Answers 11

From Haskell:

Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry.

Basically Haskell can be used to create pretty much anything you would normally create using other general-purpose languages (e.g. C#, Java, C, C++, etc.).

This is a pretty good source for info about Haskell and its uses:

Open Source Haskell Releases and Growth

upvote
  flag
Link-only answers are not ideal. That said, since this question is closed it might be better to edit than to delete. – dfeuer
2 upvote
  flag
Seems this resource hasn't been updated since 2009. – Robert Harvey
up vote 251 down vote accepted

What are some common uses for this language?

Rapid application development.

If you want to know "why Haskell?", then you need to consider advantages of functional programming languages (taken from http://c2.com/cgi/wiki?AdvantagesOfFunctionalProgramming):

  • Functional programs tend to be much more terse than their ImperativeLanguage counterparts. Often this leads to enhanced programmer productivity

  • FP encourages quick prototyping. As such, I think it is the best software design paradigm for ExtremeProgrammers... but what do I know?

  • FP is modular in the dimension of functionality, where ObjectOrientedProgramming is modular in the dimension of different components.

  • The ability to have your cake and eat it. Imagine you have a complex OO system processing messages - every component might make state changes depending on the message and then forward the message to some objects it has links to. Wouldn't it be just too cool to be able to easily roll back every change if some object deep in the call hierarchy decided the message is flawed? How about having a history of different states?

  • Many housekeeping tasks made for you: deconstructing data structures (PatternMatching), storing variable bindings (LexicalScope with closures), strong typing (TypeInference), GarbageCollection, storage allocation, whether to use boxed (pointer-to-value) or unboxed (value directly) representation...

  • Safe multithreading! Immutable data structures are not subject to data race conditions, and consequently don't have to be protected by locks. If you are always allocating new objects, rather than destructively manipulating existing ones, the locking can be hidden in the allocation and GarbageCollection system.

Apart from this Haskell has its own advantages such as:

  • Clear, intuitive syntax inspired by mathematical notation.
  • List comprehensions to create a list based on existing lists.
  • Lambda expressions: create functions without giving them explicit names. So it's easier to handle big formulas.
  • Haskell is completely referentially transparent. Any code that uses I/O must be marked as such. This way, it encourages you to separate code with side effects (e.g. putting text on the screen) from code without (calculations).
  • Lazy evaluation is a really nice feature:
    • Even if something would usually cause an error, it will still work as long as you don't use the result. For example, you could put 1 / 0 as the first item of a list and it will still work if you only used the second item.
    • It is easier to write search programs such as this sudoku solver because it doesn't load every combination at once—it just generates them as it goes along. You can do this in other languages, but only Haskell does this by default.

You can check out following links:

9 upvote
  flag
The following thought often crosses my mind: in a pure language, a function always returns the same result when passed the same parameters. This is a guarantee. Imperative languages in contrast build everything on top of "statements". A statement does not come with any sort of guarantee (except its execution consumes time and produces heat). So the foundation is already shaky and everything bult on top of it will remain shaky. To me this was one of the reasons to learn haskell. – Martin Drautzburg
upvote
  flag
Its also for controlling your Death Ray with high accuracy! yellosoft.us/evilgenius – QuantumKarl
upvote
  flag
Haskell is very, very far from what I would traditionally consider to be "RAD" in the likes of Visual Basic or Delphi. RAD is less about the language and more about tools like GUI designers and the associated generation of boilerplate by the tools. – Barend Venter
upvote
  flag
@BarendVenter, RAD is not so much about how long in minutes it takes the developer to get something on the screen, but more about the ability to "turn on a dime" during prototyping. In a typical imperative codebase, major structural changes, as is frequent in prototyping, require significant amounts of cut&paste (order of statements) and re-writing classes from scratch, even changing interfaces. – sleblanc
upvote
  flag
That Microsoft calls VB a form of rapid development is just marketing, IMO. Having a graphical builder gives you the ability to easily add widgets to an application in an intuitive manner, but that's pretty much it. Anything else can be done as easily with just a text editor. – sleblanc
upvote
  flag
It's been 6 years since this question was asked and since the Go programming language debuted. Despite having a weaker type system and generally being "objectively inferior" (according to functional/ML fans), it's managed to ship more (and more important) software in those 6 years than Haskell has in its 26 years. I mean this as a case study; there are clearly things that are holding functional languages back, and they can't all be attributed to hype. – weberc2
2 upvote
  flag
You forgot a point - coding in haskell is an absolute blast ;) I've had so much fun trying my hand at some problems in haskell. – J Atkin
5 upvote
  flag
@MartinDrautzburg Of course statements come with guarantees. What sort of useful language would have statements without guarantees? For example in C x = 5; guarantees that after it executes, x contains the value 5. – immibis
upvote
  flag
You probably meant: For example, you could put 1 / 0 as the second item of a list and it will still work if you only used the first item. – lovasoa
1 upvote
  flag
@immibis x = 5 in C++ definitely does not guarantee that x contains the value 5 after it executes (operator overloading). @lovasoa Both statements are true, since it is possible to access and evaluate the second item in a list without evaluating the first item in a list. – E4z9
3 upvote
  flag
@E4z9 Yeah but in C++ it guarantees that operator = is called. And it guarantees what happens if you don't define an operator = – immibis
upvote
  flag
@immibis in C x=5; doesn't guarentee that x will equal 5 in a multithreaded program ;) – niceman
upvote
  flag
@niceman Sure it does. It doesn't guarantee that you won't set x to something else before the next statement executes, however. – immibis
upvote
  flag
@immibis no it doesn't, you could have torn writes – Passer By
upvote
  flag
@PasserBy Well then you just need to update the guarantee. x=5; guarantees that x will equal 5 if there is no way that x could be simultaneously modified in another thread or if x is a type that can be atomically written or if you're on a weak consistency model. That doesn't invalidate the point that there are guarantees. (Alternatively, you could state that you are guaranteeing to the compiler that you won't modify x in multiple threads, and if you break your guarantee the compiler is free to break its). – immibis
upvote
  flag
@immibis That's a great guarantee :) – Passer By
upvote
  flag
@PasserBy Better than Haskell's "this expression will always evaluate to an integer unless it's undefined or it uses unsafe functions or calls foreign code that breaks this or that rule"? – immibis
1 upvote
  flag
@immibis I actually meant that not sarcastically. I don't actually know enough of Haskell to comment on how great Haskell's guarantees are, which is why I'm here – Passer By

One example of Haskell in action is xmonad, a "featureful window manager in less than 1200 lines of code".

From the Haskell Wiki:

Haskell has a diverse range of use commercially, from aerospace and defense, to finance, to web startups, hardware design firms and lawnmower manufacturers. This page collects resources on the industrial use of Haskell.

According to Wikipedia, the Haskell language was created out of the need to consolidate existing functional languages into a common one which could be used for future research in functional-language design.

It is apparent based on the information available that it has outgrown it's original purpose and is used for much more than research. It is now considered a general purpose functional programming language.

If you're still asking yourself, "Why should I use it?", then read the Why use it? section of the Haskell Wiki Introduction.

There is one good answer for what a general purpose language like Haskell is good for: writing programs in general.

For what it is used for in practice, I've three approaches to establishing that:

Indicates that it is good for graphics, networking, systems programming, data structures, databases, development, text processing ...

And finally, my opinion on what it is really strong at:

I hope that gives you a sense on how broad your question is, if it is to be answered with any specificity.

12 upvote
  flag
Tag cloud is broken – Elliot Cameron
upvote
  flag
was the tag cloud generated using wordcloud? – Janus Troelsen

Haskell is a general purpose programming language. It can be used for anything you use any other language to do. You aren't limited by anything but your own imagination. As for what it's suited for? Well, pretty much everything. There are few tasks in which a functional language does not excel.

And yes, I'm the Rayne from Dreamincode. :)

I would also like to mention that, in case you haven't read the Wikipedia page, functional programming is a paradigm like Object Oriented programming is a paradigm. Just in case you didn't know. Haskell is also functional in the sense that it works; it works quite well at that.

Just because a language isn't an Object Oriented language doesn't mean the language is limited by anything. Haskell is a general-purpose programming language, and is just as general purpose as Java.

I think people in this post are missing the most important point for anyone who has never used a functional programming language: expanding your mind. If you are new to functional programming then Haskell will make you think in ways you've never thought before. As a result your programming in other areas and other languages will improve. How much? Hard to quantify.

1 upvote
  flag
I'm using an iPhone, Mac. Where is Haskell used? I mean for the apps I used they are written in Objective-C or Swift + something for database and servers. Swift can also be functional. So again I'm confused as to where it's used – Honey
1 upvote
  flag
Facebook does SPAM detection with it: code.facebook.com/posts/745068642270222/… – axaluss
11 upvote
  flag
This answer, written in a different tone, says that Haskell is a great exercise for a programmer, which IMO doesn't make a great general purpose language – Passer By
1 upvote
  flag
At Keera Studios we write iOS and Android games and apps using Haskell. – Ivan Perez

I have a cool one, facebook created a automated tool for rewriting PHP code. They parse the source into an abstract syntax tree, do some transformations:

if ($f == false) -> if (false == $f)

I don't know why, but that seems to be their particular style and then they pretty print it.

https://github.com/facebook/lex-pass

We use haskell for making small domain specific languages. Huge amounts of data processing. Web development. Web spiders. Testing applications. Writing system administration scripts. Backend scripts, which communicate with other parties. Monitoring scripts (we have a DSL which works nicely together with munin, makes it much easier to write correct monitor code for your applications.)

All kind of stuff actually. It is just a everyday general purpose language with some very powerful and useful features, if you are somewhat mathematically inclined.

4 upvote
  flag
Re: the FB style, putting the false before the == means if you forget and only write a single = then the resulting behavior will be more obviously wrong instead of silently performing an unintended assignment operation and continuing normally – Magnus
upvote
  flag
A that's clever, your force that particularly error to be known compile time then. – Edgar Klerks
upvote
  flag
@EdgarKlerks, PHP has no compile time. This forces the exception to be raised where the mistake was, rather than leading to bizarre behavior or errors in distant code. – dfeuer
upvote
  flag
Although I see the benefit of writing false on the left, I don't see the point of using a tool to do it automatically: if you've already got a == operator then you already know you don't have the bug which that part of lex-pass is meant to catch, and if you've got a = instead there's no sure way to tell whether or not it's like that deliberately. – Jeremy List
1 upvote
  flag
@JeremyList Maybe they are really stringent on the coding style. I can see that neatly formatted code invites to write more neatly formatted code. Just a wild guess. – Edgar Klerks
upvote
  flag
@dfeuer But it has a phase where it builds up a symbol table? Maybe they catch it there then? Nevermind, this is off topic babble. I probably better check the source code myself. – Edgar Klerks
upvote
  flag
I am a newbie to Haskell but find it relatively simple to explore machine learning codes with Haskell (such as kNN classifier and perceptron) – stian

For example, for developing interactive, realtime HTML5 web applications. See Elm, the compiler of which is implemented in Haskell and the syntax of which borrows a lot from Haskell's.

Not the answer you're looking for? Browse other questions tagged or ask your own question.