Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help a Haskell noob

Name: Anonymous 2009-05-07 2:41

I'm running into a funny error, and since you guys hold Haskell second only to Scheme, I though I'd see if you could help me...

I'm trying to get the following code to work:

qLearningUpdate :: ((a,s),n) -> s -> n
qLearningUpdate q s' =
    (fromListBy 0 (maximum.snd.unzip)) (getActions s' q)
    where getActions :: [((a,b),c)]-> b -> [(a,c)]
          getActions s q = (filter ((==s).snd.fst)) q
          fromListBy :: b -> ([a] -> b) -> [a] -> b
          fromListBy d f [] = d
          fromListBy d f xs = f xs


When I just evaluate (fromListBy 0 (maximum.snd.unzip)) (getActions someVariable someAssocList) in ghci , it works fine. When I try to compile the code, I get the following error:

project4.hs:7:0:
    Occurs check: cannot construct the infinite type: n = [((a, s), n)]
    When generalising the type(s) for `qLearningUpdate'

What the hell, man?

Name: Anonymous 2009-05-07 8:34

GHCi, version 6.10.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
'-._                  ___.....___
    `.__           ,-'        ,-.`-,
        `''-------'          ( p )  `._
                              `-'      (  Have you read your YAHT today?
                                        \
                              .         \
                               \---..,--'
   ................._           --...--,
                     `-.._         _.-'
                          `'-----''                         Type :ihbt for help.
Prelude>

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List