Code doesn't execute. Haskell for Mac complains about "bare expressions".

The main Haskell for Mac window consists of three main areas:

  1. To the very left, there is the project navigator listing all the files in your project.
  2. In the middle is the Haskell module editor, where you put all the code for your application.
  3. On the right is the Haskell playground (which itself has two columns: an editor pane in the left column for Haskell expressions to be evaluated and the results view in the right column).

On the right side of the toolbar is a segmented control that enables you to hide and show these three main areas.

The Haskell module editor (middle area) expects entire Haskell modules that usually start with something along the lines of module MODULE_NAME where, whereas the playground editor (right area) expects individual Haskell expression or declarations that are executed one by one.

If you accidentally enter a Haskell expression for evaluation in the module editor, it will complain about a "bare expression". Please try the expression in the playground editor instead. For more information on how to write Haskell modules, please have a look at our tutorial Learning Haskell.

If you want to define a new variable or a function in the playground (as opposed to the module editor), you need to prefix the definition with the keyword let. For example, you would write

let x = 5


let fact 0 = 1
    fact n = n * fact (n - 1)

For more information, see our overview page The Anatomy of Haskell for Mac.

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk