Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the most important abstractions in Haskell? Monads? Applicatives? [closed]

Tags:

I want to know which libraries, functions, and concepts I definitely should know about and how to use. Monad and the functions there is the typical example, but there are other good primitives to use in coding, like Arrows, Applicative, ... Who are they?

btw, I want to be up-to-date in the Haskell world, learning the new concepts, how is this done?

(the original title was: "Library primitives for coding", but this was changed)

like image 840
telephone Avatar asked May 14 '11 17:05

telephone


People also ask

Why doesn’t the Haskell monadclass require a function?

That is not an accident. Nothing prevents the monad author from allowing it using functions specific to the monad. For instance, values can be extracted from the Maybemonad by pattern matching on Just xor using the fromJustfunction. By not requiring such a function, the Haskell Monadclass allows the creation of one-way monads.

What is a one-way monad in Haskell?

By not requiring such a function, the Haskell Monad class allows the creation of one-way monads. One-way monads allow values to enter the monad through the return function (and sometimes the fail function) and they allow computations to be performed within the monad using the bind functions >>= and >>,...

Where can I find documentation for monads in Haskell?

Some of the documentation for these monads comes from the excellent Haskell Wiki. In addition to the monads covered here, monads appear many other places in Haskell, such as the Parsecmonadic combinator parsing library. These monads are beyond the scope of this reference, but they are thoroughly documented on their own.

What is the best order to define return types in Haskell?

although the recommended order is to define return as pure if the two would otherwise end up being the same. Nondeterminism using List monad to represent carrying multiple values In order to improve the look of code that uses monads, Haskell provides a special form of syntactic sugar called do -notation. For example, the following expression:


2 Answers

The best way to start your Haskell experience is to install The Haskell Platform, which has many of the libraries we think are important.

  • The library documentation
  • Other advice for learning Haskell

If you look at what abstractions ship in the base system, you'll see some things worth learning:

  • Control.Monad
  • Control.Applicative
  • Control.Arrow
  • Data.Monoid
  • Monad transformers
  • The ST Monad

And don't forget the powerful tools:

  • Concurrent programming
  • Transactional memory
  • Deterministic parallelism
like image 191
Don Stewart Avatar answered Oct 04 '22 11:10

Don Stewart


Basic libraries to know:

  • base (Prelude module, etc)
  • Monad Transformer Library, mtl or the MonadLib.
  • containers

Common data-centric libraries:

  • cereal / binary / blaze-builder
  • Vector
  • unordered-containers

Packaged concepts that you should know:

  • Monads, Monad Transformers (see base, mtl)
  • Applicative (see base)
  • Arrows (see base)
  • Software Transactional Memory (stm)
  • Extensible Exceptions (in base since ~GHC 6.8)
  • Dynamic programming in Haskell (See Data.Typeable in base)
  • Sparking (light-weight parallelism hints via parallel)
  • Concurrency (see Control.Concurrent in base)
  • Memoization (monad-memo, MemoTrie)

Semi-advanced concepts:

  • Functional Reactive Programming (reactive-banana, netwire)
  • Iteratees (enumerator)
  • Generic programming (syb, uniplate, etc)

Testing, benchmarking, and infrastructure:

  • criterion (benchmarking tool)
  • quickcheck, lazysmallcheck (property tests)
  • cabal and hackage

External tools, GHC helpers, GHC

  • threadscope
  • alex (lexer)
  • happy (a parser generator)
  • haddock (documentation system)
  • Haskell Program Coverage (HPC)
  • GHC manual, which includes information on things like
    • Different back-ends
    • Profiling
    • Debugging
    • Optimization
    • Language extensions

Type-centric knowledge

  • GADTs
  • Rank-N Types
  • Existentials
  • Functional Dependencies and Type Families
  • This list can go on and on, but you'll know where to look if you know the above.

How to stay up-to-date on Haskell without asking a stack-overflow question:

  • Read the papers accepted by ICFP and POPL
  • Read the papers rejected by ICFP and POPL (if you can find them)
  • Connect on the social networks, Haskellers seem big on
    • Twitter (start by following whoever follows Galois or any random Haskeller you know)
    • Reddit
    • Stack Overflow (message me if you need a link)
  • Read blogs (linked from reddit or planet.haskell.org)
  • Follow conversations on the haskell-cafe mailing list or IRC.
  • Attend Galois semi-weekly tech talks
like image 28
Thomas M. DuBuisson Avatar answered Oct 04 '22 10:10

Thomas M. DuBuisson