Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,869
    • Issues 4,869
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19097
Closed
Open
Created Dec 21, 2020 by Marc Scholten@mpscholten

Improve error message on wrong indentation of let expression inside do block

Given this code:

    action NewEventAction = do
        now <- getCurrentTime
        let event = newRecord @Event
            |> set #createdAt now -- THIS LINE NEEDS MORE INDENTATION
        render NewView { .. }

GHC errors with:

Admin/Controller/Events.hs:26:9: error:
    The last statement in a 'do' block must be an expression
      let event = newRecord @Event
   |
26 |         let event = newRecord @Event
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

A better error message would be:

Admin/Controller/Events.hs:26:9: error:
    The let-expression is only indented 4 spaces from the do-statement, but it needs to be indented 8 spaces
      '|> set #createdAt now'
   |
26 |         let event = newRecord @Event
27 |             |> set #createdAt now
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

This issue has happend during a twitch livestream of someone building an IHP app for the first time. Here's a link to the video of that livestream: https://youtu.be/Bncy8JiHDYU?t=4939 At 1:22:19 the user get's stuck. It's kind of interesting to watch as you can see how the error message is a bad UX for someone new to haskell :) Hope we can improve this.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking