tweag / ormolu

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

Certain arrow expressions cause "not implemented yet: HsCmdApp" #716

Closed robx closed 3 years ago

robx commented 3 years ago

Describe the bug Running ormolu on valid Haskell source files with Arrows extension cause ormolu to exit with "ormolu: not implemented yet: HsCmdApp". It seems the core fragment is (| ... |) thing, i.e. the extra word after the brackets.

To Reproduce

$ cat Arrows.hs
{-# LANGUAGE Arrows #-}

f = proc x -> do
        y <- f -< x+1
        (| runReader (returnA -< ()) |) y
$ ormolu Arrows.hs
ormolu: not implemented yet: HsCmdApp
CallStack (from HasCallStack):
  error, called at src/Ormolu/Utils.hs:59:22 in rml-0.1.4.1-f355d56b:Ormolu.Utils

Expected behavior I expect ormolu to run successfully.

Environment

Additional context

GHC documentation; this example was pieced together from that: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/arrows.html#primitive-constructs Source code comment says to ping @yumiova.

robx commented 3 years ago

It turns out the brackets aren't the problem, here's a simpler test case from the GHC test suite:

{-# LANGUAGE Arrows #-}

module ShouldCompile where

import Control.Arrow

g :: ArrowChoice a => Int -> a (Int,Int) Int
g x = proc (y,z) -> (case compare x y of
        LT -> \ a -> returnA -< x+a
        EQ -> \ b -> returnA -< y+z+b
        GT -> \ c -> returnA -< z+x
    ) 1