bch29 / robo-monad

Heavily inspired by RoboCode. Program robots in Haskell and watch them fight.
GNU General Public License v3.0
15 stars 2 forks source link

<$> Not in scope #1

Closed jgcoded closed 9 years ago

jgcoded commented 9 years ago

I tried to build the most current master (3e81ff1805e870d773af5dfd4a0422f510559091), but I received this error:

src\Game\Robo\Core.hs:82:29:
    Not in scope: `<$>'
    Perhaps you meant `<>' (imported from Control.Monad.Writer.Strict)
[ 7 of 16] Compiling Game.Robo.Maths  ( src\Game\Robo\Maths.hs, dist\build\Game\Robo\Maths.o )
[ 8 of 16] Compiling Game.Robo.PID.Class ( src\Game\Robo\PID\Class.hs, dist\build\Game\Robo\PID\Class.o )
[ 9 of 16] Compiling Game.Robo.PID    ( src\Game\Robo\PID.hs, dist\build\Game\Robo\PID.o )
[10 of 16] Compiling Game.Robo.PID.Lensed ( src\Game\Robo\PID\Lensed.hs, dist\build\Game\Robo\PID\Lensed.o )```
bch29 commented 9 years ago

That'll be because I haven't tested it with anything other than GHC 7.10. Should be an easy fix.

jgcoded commented 9 years ago

I'm using GHC 7.8.3 obtained from https://www.haskell.org/platform/. It doesn't provide GHC 7.10, unfortunately.

bch29 commented 9 years ago

There we go, I think it should compile now unless there's anything else I've missed.

jgcoded commented 9 years ago

What version of lens do you have? The error is slightly different:

src\Game\Robo\Core.hs:82:29:
    Not in scope: `<$>'
    Perhaps you meant `<>' (imported from Control.Monad.Writer.Strict)
bch29 commented 9 years ago

Sorry, that first time didn't fix it because I merged the change into a local branch instead of the one that was pushed to GitHub. I pushed an actual fix about 30 minutes ago. That error has nothing to do with lens -- <$> is from Control.Applicative (but it's in Prelude for GHC 7.10).

jgcoded commented 9 years ago

I now get this:

src\Game\Robo\Core.hs:83:29:
    Could not deduce (Functor m) arising from a use of `<$>'
    from the context (Monad m)
      bound by the type signature for
                 applyAllBots :: Monad m =>
                                 [ContextT BotState m a] -> ContextT WorldState m [a]
      at src\Game\Robo\Core.hs:79:17-79
    Possible fix:
      add (Functor m) to the context of
        the type signature for
          applyAllBots :: Monad m =>
                          [ContextT BotState m a] -> ContextT WorldState m [a]
    In a stmt of a 'do' block:
      (res, newStates) <- unzip <$> zipWithM runfun bots botStates
    In the expression:
      do { botStates <- use wldBots;
           let runfun action st = lift $ runStateT action st;
           (res, newStates) <- unzip <$> zipWithM runfun bots botStates;
           wldBots .= newStates;
           .... }
    In an equation for `applyAllBots':
        applyAllBots bots
          = do { botStates <- use wldBots;
                 let runfun action st = ...;
                 (res, newStates) <- unzip <$> zipWithM runfun bots botStates;
                 .... }

I'll upgrade to 7.10 and try it again

bch29 commented 9 years ago

That should be fixed now too hopefully!

If you do want to try it with GHC 7.10, I'd recommend installing stack.

jgcoded commented 9 years ago

So that part of Core finally built! Now it's complaining in the examples. Crazy and Wallhugger compile, but I get this now:

demo\BulletTester.hs:56:22: Not in scope: `<$>'

I'll switch to stack, it looks easier than cabal.

bch29 commented 9 years ago

Please tell me it works now? :P

jgcoded commented 9 years ago

Yes! All good now. Thank you!