What is Haskell used for in the real world?

HaskellFunctional ProgrammingProgramming Languages

Haskell Problem Overview


There is a lot of hype around Haskell, however, it is hard to get information on how it is used in the real world applications. What are the most popular projects / usages of Haskell and why it excels at solving these problems?

Haskell Solutions


Solution 1 - Haskell

> 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 https://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:

Solution 2 - Haskell

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.

Solution 3 - Haskell

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.

Solution 4 - Haskell

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

Solution 5 - Haskell

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.

Solution 6 - Haskell

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.

Solution 7 - Haskell

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.

Solution 8 - Haskell

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.).

Solution 9 - Haskell

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.

Solution 10 - Haskell

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

Open Source Haskell Releases and Growth

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSergio TapiaView Question on Stackoverflow
Solution 1 - HaskellXinusView Answer on Stackoverflow
Solution 2 - HaskellwheatiesView Answer on Stackoverflow
Solution 3 - HaskellDon StewartView Answer on Stackoverflow
Solution 4 - HaskellunutbuView Answer on Stackoverflow
Solution 5 - HaskellRobert GrovesView Answer on Stackoverflow
Solution 6 - HaskellRayneView Answer on Stackoverflow
Solution 7 - HaskellEdgar KlerksView Answer on Stackoverflow
Solution 8 - HaskellAndrew HareView Answer on Stackoverflow
Solution 9 - HaskellthSoftView Answer on Stackoverflow
Solution 10 - HaskellRobert HarveyView Answer on Stackoverflow