Guard is skipped when it should not be.
I have the following snippet of code

    module Main where
    
    main :: IO()
    main = do
       ne <- getLine
       c <- getLine
       putStrLn $ show $ foo c (words ne)
    
    foo :: String -> [String] -> Integer
    foo c (n:e:_) =
       foo' (read c::Integer) (read e::Integer) (read n::Integer) [2..]
       where foo' c e n (x:xs)
          | mod (x^e) n == c = mod x n
          | otherwise = foo' c e n xs

Which works as expected except when given the following input:

    9 3 
    2

The first guard is skipped and an infinite loop is entered.
The way I see this is that
`foo'` should first be called with `2 3 9` which would result in `mod (2^9) 3 == 2` which is true and should result in the value `mod 2 9` but this is not the case.

I am sure I am missing something trivial here, but I just cant see it...

Guard is skipped when it should not be.
===

I have the following snippet of code

    module Main where
    
    main :: IO()
    main = do
       ne <- getLine
       c <- getLine
       putStrLn $ show $ foo c (words ne)
    
    foo :: String -> [String] -> Integer
    foo c (n:e:_) =
       foo' (read c::Integer) (read e::Integer) (read n::Integer) [2..]
       where foo' c e n (x:xs)
          | mod (x^e) n == c = mod x n
          | otherwise = foo' c e n xs

Which works as expected except when given the following input:

    9 3 
    2

The first guard is skipped and an infinite loop is entered.
The way I see this is that
`foo'` should first be called with `2 3 9` which would result in `mod (2^9) 3 == 2` which is true and should result in the value `mod 2 9` but this is not the case.

I am sure I am missing something trivial here, but I just cant see it...
