[Haskell-beginners] Re: calling polymorphic function in Selenium question

MH mhamro at gmail.com
Fri Apr 16 10:20:43 EDT 2010


I tried that and I got the following error:

A pattern type signature cannot bind scoped type variables `a'
      unless the pattern has a rigid type context
    In the pattern: x :: Selenium a -> IO (Either String a)
    In a stmt of a 'do' expression:
        (x :: Selenium a -> IO (Either String a)) <- start
                                                       "
https://www.google.com"
    In the expression:
        do { (x :: Selenium a -> IO (Either String a)) <- start "
https://www.google.com";


Then I tried to add "forall a" but the Selenium library doesn't use forall
so there was a conflict. Is there a way to work around the rigid type error
you know of?

Thanks

On Apr 15, 3:14 pm, Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> On Sun, Apr 04, 2010 at 09:25:16PM -0400, MH wrote:
> > I am running the following code that is using Selenium. If you look at
> > the function "start", you will see that the return type of the
> > function is polymorphic. Now in main function, I call start function
> > to get selenium IO monad and sequentially call selenium commands
> > (open, doCommand etc...). The problem that I have here is, while I can
> > call all Selenium commands with signature (String  -> Selenium
> > String), I can't call commands with signature (String  -> Selenium
> > Bool). As I understand it, even though "start" function shall return
> > IO (Selenium a -> IO (Either String a)), it actually return IO
> > (Selenium String -> IO (Either String String)).
>
> Hmm, I must confess that I don't understand exactly what is going on
> here.  One thing to try is to give an explicit type annotation at
> start's call site, something like
>
> > main = do
> >     (selenium :: Selenium a -> IO (Either String a)) <- start "
http://www.google.com"
> >     selenium $ open "/"
> >     selenium $ doCommand SWindowMaximize []
> >     selenium $ typeText (Name "q") "stuff"
> >     selenium $ clickAndWait (Name "btnG")
> >      return selenium
>
> Does that help?
>
> -Brent
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.orghttp://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100416/3cbc91cf/attachment.html


More information about the Beginners mailing list