kallisti-dev/hs-webdriver — pull request #31 by zerobuzz (2014-03-24 09:33:46+00:00)
Title: Refactor WebDriver monad to allow for code generation

Hei,

Please don't pull this! So far it's just pseudo-code, and important parts are missing. I am creating this ticket in the form of a pull request because I think it's easier for everybody involved.

I want to use webdriver for generating unit tests in python. I want the same test functions of the form:

> someproperty :: WebDriver wd => SomeInputType -> wd SomeResultType

to be usable for both python code generation and running them as currently intended.

Currently, WebDriver implies SessionState, but that's no good, because when I generate python code that runs the webdriver session later, I do not want anything to do with SessionState (yet).

I want everything to keep working as it is on the surface. Additionally, I want to define a new type

> data WDF a

as in the pseudo-code of this pull request.

0. Are there any objections to my approach that are obvious for somebody with better understanding of webdriver internals?

1. Making doSessCommand and friends class methods creates a cyclical dependency. I hate those. :)

2. I don't know how to mimic the result values of intermediate commands if I am not actually running the entire thing until much later. I think free monads may be a solution, but I am still trying to figure out how. There is 'free' by kmett on hackage and an introduction to the concept by Andres Löh (Skills Matter Haskell Exchange 2013).

I would appreciate your feedback before I continue: Are you open to making any changes that will allow me to meet my requirements? Do you have a better idea how? (We did talk about this before in, I think, January this year, but then I got distracted. But my need won't go away!)

thanks,
m.