[Haskell] arrows

ross at soi.city.ac.uk ross at soi.city.ac.uk
Wed Sep 15 13:47:50 EDT 2004


On Wed, Sep 15, 2004 at 03:38:43PM +0200, Sebastian Boldt wrote:
> I am a bit confused about command stacks. I tried to run the following 
> code in ghc:
> 
> mshowA :: (Arrow a, Show b) => a (b, String) String
> mshowA = proc (x,s) -> returnA -< s ++ show x ++ s
> 
> f :: Arrow a => a Int String
> f = proc x -> do a <- (mshowA -< x) "***"
>                  returnA -< a
> 
> To my understanding (this doesn't mean anything :-) this is correct 
> because (mshowA -< x) "***" should be equivalent to (mshowA -< (x,"***")),
> but somehow ghc is rejecting the code with the error message "Non-empty 
> command stack at command: mshowA -< x".

Yes, the error message isn't terribly friendly.

In the GHC implementation, the typechecker forbids application commands
(-< and -<<) from being applied to anything.  As you point out, this
seems an unnecessary restriction, so I've removed it from the version
that will become GHC 6.4.

(A similar restriction on do commands is still there.)


More information about the Glasgow-haskell-users mailing list