tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
958 stars 83 forks source link

Support arrow notation #491

Closed dandoh closed 4 years ago

dandoh commented 4 years ago

Ormolu fails to parse arrow notation proc () ->:

module Database.User where

import Control.Arrow (returnA)
import Data.Text (Text)
import Database.Model
import GHC.Int (Int64)
import Opaleye

-------------------------------------------------------------------------------
userSelect :: Select UserF
userSelect = selectTable userTable

-------------------------------------------------------------------------------
insertUser :: (Text, Text, Text) -> Insert Int64
insertUser (userEmail, userPasswordHash, userName) =
    Insert
        { iTable = userTable
        , iRows =
              [ UserData
                    { userId = Nothing
                    , userEmail = toFields userEmail
                    , userPasswordHash = toFields userPasswordHash
                    , userName = toFields userName
                    }
              ]
        , iReturning = rCount
        , iOnConflict = Nothing
        }

-------------------------------------------------------------------------------
findUserByEmail :: Text -> Select UserF
findUserByEmail email =
    proc () ->
  do user <- userSelect -< ()
     restrict -< (userEmail user) .== toFields email
     returnA -< user
mrkkrp commented 4 years ago

Have you enabled the corresponding language extension?

dandoh commented 4 years ago

@mrkkrp I put in in package.yaml, do I have to put it on the file?

mrkkrp commented 4 years ago

package.yaml doesn't mean anything to Ormolu. There are two ways to make it aware of language extensions: 1) put them on the top of each module (recommended) 2) pass with --ghc-option, i.e. --ghc-option -XArrows.

dandoh commented 4 years ago

Confirm it works if I enable them in the file.