[Haskell-cafe] Subsequence near solved hopefully

Remi Turk rturk at science.uva.nl
Sun Oct 17 10:57:22 EDT 2004


On Sun, Oct 17, 2004 at 07:16:51AM -0700, Peter Stranney wrote:
> equalString :: String -> String -> Bool
> equalString [] [] = True
> equalString [] (c':s') = False
> equalString(c:s) [] = False
> equalString(c:s)(c':s') = equalChar c c'^ equalString s s'
                                       ^^^^^^
>  
> this function is to see if one string is equal to another.
>  
> but when i compile this i get the error;
> - Instance of Integral Bool required for definition of equalString

You are using the raise-to-the-power-of operator, which requires
it's second parameter to be Integral...

(^) :: (Integral b, Num a) => a -> b -> a

You might also want to look at the earlier `any prefix of tails'
suggestion, as it makes the solution a rather simple one-liner.

Good luck,
Remi

-- 
Nobody can be exactly like me. Even I have trouble doing it.


More information about the Haskell-Cafe mailing list