Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

update to argonaut 7 and affjax 11 #13

Merged
merged 1 commit into from
Nov 19, 2020
Merged

Conversation

srghma
Copy link
Contributor

@srghma srghma commented Nov 16, 2020

No description provided.

@cryogenian
Copy link
Member

Please don't remove bower for now. Having both spago and bower seems redundant but not a big deal I think 🙂

@srghma
Copy link
Contributor Author

srghma commented Nov 17, 2020

@cryogenian done

@srghma
Copy link
Contributor Author

srghma commented Nov 18, 2020

@cryogenian in 661bb41

BaseEffects or LunaparkBaseEffects (as is) ?

Copy link
Member

@cryogenian cryogenian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems almost done! 👍

Just a couple of smallish comments

src/Lunapark/API.purs Outdated Show resolved Hide resolved
@@ -32,49 +33,49 @@ derive instance functorTouchF ∷ Functor TouchF

_lunaparkActions = SProxy ∷ SProxy "lunaparkActions"
type LUNAPARK_ACTIONS = R.FProxy ActionF
type WithAction r = R.Run (lunaparkActions ∷ LUNAPARK_ACTIONS|r) Unit
type LunaparkActionsEffect r = ( lunaparkActions ∷ LUNAPARK_ACTIONS | r )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind, but could you please share your motivation here? Is it because BaseEffect andWithAction is unclear?

Copy link
Contributor Author

@srghma srghma Nov 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseEffect? You prob mean BaseRun

the reason is that it's easier to understand when Run is not in type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means that instead of this

myAwesomeTest :: forall r. Lunapark r
myAwesomeTest = do 
  go "http://whatever.com"
  clickEl selector

End-users will need to write this

myAwesomeTest:: forall r. Run (LunaparkBaseEffects + LunaparkEffect + LunaparkActionsEffect + r)
myAwesomeTest = do 
  go "http://whatever.com"
  clickEl selector

Removing Lunapark r complicates basic use-case and propagates implementation details to the call site, I think it should be preserved. I'm fine with removing WithAction, BaseRun and using Run (Whatever r) inside the library, but don't agree with removing main library monad synonim from public API. I'd say that making Lunapark r a newtype might be good idea, but not in this pr 🙂

Personally, I think that this Lunapark r (not WithAction r and definitely not BaseRun r) are somewhat like CodecJson, not F (ugh... F from foreign is terrible)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. returned type Lunapark

  2. re newtyping - not sure if I like this idea

I'm fine with doing

Run (LunaparkBaseEffects + LunaparkEffect + LunaparkActionsEffect + r)

actually I removed BaseRun so I could easiter to this to see what is going on

I like when I see ok, I'm using the Run lib, not something else

src/Lunapark/Endpoint.purs Show resolved Hide resolved
= JsonDecodeError J.JsonDecodeError
| WebdriverError LWE.WebdriverError
| AffjaxError N.Error
| UserError String
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is actually LunaparkError not UserError as it's internal thing for lunapark

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cryogenian

how about rename UserError to InternalError (since it is only in lib)

and rename LunaparkF to BaseActionF?

I think there is too much Lunapark in lunapark

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe LunaparkF to ActionF and ActionF to CompoundActionF?

Copy link
Member

@cryogenian cryogenian Nov 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's not internal, right? More like it's compound or domain level, what about CompoundError?

LunaparkF -> ActionF and ActionF -> CompoundActionF break webdriver naming scheme, because ActionF is actually about actions in webdriver (they are encoded as action field and discussed in action section of docs. I'd agree that LunaparkActionEffect -> ActionEffect is OK, but, yeah, ActionEffect sounds a bit too generic to me, although it's definitely acceptable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. re errors

I think I have found the best variant e7428d9

  1. re renaming

I have finally understood the ActionF

it transforms

my = do
  ActionF.sendKeys "a"
  ActionF.pause
  LunaparkF.foo
  ActionF.sendKeys "a"
  ActionF.pause

to

my = do
  LunaparkF.performActions $ Object.fromHomogenous
    { "id1": Key [keyDown "a", keyUp "a", pause]
    }
  LunaparkF.foo
  LunaparkF.performActions $ Object.fromHomogenous
    { "id1": Key [keyDown "a", keyUp "a", pause]
    }

spec https://github.com/jlipps/simple-wd-spec#perform-actions

but also supports deprecated json wire

wow this complicated


  1. renaming is done in e60fd79

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's how it works. We had problems where ff driver and chromedriver were supporting only subsets of actual webdriver API.

src/Lunapark/Error.purs Outdated Show resolved Hide resolved
src/Lunapark/Utils.purs Outdated Show resolved Hide resolved
test/Main.purs Outdated Show resolved Hide resolved
src/Lunapark/Error.purs Outdated Show resolved Hide resolved
@srghma
Copy link
Contributor Author

srghma commented Nov 19, 2020

ok, I think that's all

Copy link
Member

@cryogenian cryogenian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thing we agreed on all changes here 🎉

There is a couple of leftover comments and other tiny stuff.

packages.dhall Outdated
@@ -0,0 +1,111 @@
{-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this comment I think

spago.dhall Outdated
@@ -0,0 +1,19 @@
{-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

post' ∷ String → Endpoint → Aff (Either LE.Error Json)
post' uri ep = map handleAPIError $ N.post NR.json (uri <> print ep) Nothing

-- | post_ ∷ String → Endpoint → Aff (Either LE.Error Unit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover comment

| CachingError CachingError

printError :: Error -> String
printError =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use unicode, and
  • The indetntation is kinda strange anyways Something like this should be aligned with other code
printError  Error  String
printError = case _ of
  JsonDecodeError jsonDecodeErrro →
    J.printJsonDecodeError jsonDecodeError
  WebDriverError webdriverError →
    "Response with error message:\n"
    <> "  error type: " <> LWE.toStringCode webdriverError.error <> "\n"
    <> "  message: " <> webdriverError.message <> "\n"
    <> "  stacktrace: " <> webdriverError.stacktrace
  AffjaxError affjaxError →
    N.printError affjaxError
  CachingError cachingError →
    "Error during caching:\n  " <> printCachingError cachingError
  where
    printCachingError = case _ of
      EmptyCases key → "There is no working implementation for " <> key <> " action."
      IncorrectCache key → "Trying another implementation for " <> key <> " action."

@@ -1,14 +1,14 @@
-- | This module contains types for requests and response.
-- | Most of them are records with `α → Json` and `Json → Either String α` functions
-- | Most of them are records with `α → J.Json` and `Json → Either J.JsonDecodeError α` functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto replace? 🙂 The second Json should have J. or all of them shouldn't have J.

import Lunapark.WebdriverError as LWE
import Data.Argonaut.Decode (JsonDecodeError, printJsonDecodeError) as J

data CachingError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

bower.json Outdated
@@ -26,7 +26,7 @@
],
"dependencies": {
"purescript-affjax": "^9.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not-updated dep

@srghma
Copy link
Contributor Author

srghma commented Nov 19, 2020

done

@cryogenian
Copy link
Member

The build is failing

@cryogenian
Copy link
Member

Thank you very much

@cryogenian
Copy link
Member

Can you please squash commits to clean history up? I don't want to remove you from authors here

commit 3b7c111
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 18:36:44 2020 +0200

    fix: ci

commit 1831afa
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 18:15:29 2020 +0200

    fix: review -> commments and style

commit f94fc1a
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 17:41:22 2020 +0200

    fix: review -> return type Lunapark

commit 95ba053
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 17:36:30 2020 +0200

    fix: review -> indentation

commit e60fd79
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 17:34:32 2020 +0200

    fix: review -> rename LunaparkActionsEffect to ActionsEffect

commit b3abe29
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 17:11:39 2020 +0200

    refactor: add comment

commit e7428d9
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 16:38:53 2020 +0200

    fix: review -> fine grain tryAndCache errors

commit 89c37e4
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 12:12:16 2020 +0200

    fix: review -> rename throwLeftJsonDecodeError to rethrowAsJsonDecodeError and remove throwLeftUserError

commit 50f546e
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 12:06:00 2020 +0200

    fix: review -> remove test

commit 2c254f4
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 12:05:31 2020 +0200

    fix: review -> dont export handleAPIError

commit 8ec2b5c
Author: Serhii Khoma <srghma@gmail.com>
Date:   Thu Nov 19 11:47:25 2020 +0200

    fix: review -> remove extra |

commit 49e194e
Author: Serhii Khoma <srghma@gmail.com>
Date:   Wed Nov 18 19:24:48 2020 +0200

    feat: remove WithAction and WithLunapark, use rows

commit 661bb41
Author: Serhii Khoma <srghma@gmail.com>
Date:   Wed Nov 18 19:04:42 2020 +0200

    refactor: remove BaseRun and Lunapark, add LunaparkBaseEffects, LunaparkEffect, LunaparkActionsEffect

commit c8dfbf1
Author: Serhii Khoma <srghma@gmail.com>
Date:   Wed Nov 18 13:27:30 2020 +0200

    feat: rename post_ to post' to match post_ function from Affjax

commit c29e049
Author: Serhii Khoma <srghma@gmail.com>
Date:   Tue Nov 17 15:01:20 2020 +0200

    feat: update npm packages

commit 69c22bb
Author: Serhii Khoma <srghma@gmail.com>
Date:   Tue Nov 17 14:44:45 2020 +0200

    feat: return bower

commit 56eb0b4
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 20:36:00 2020 +0200

    feat: printError

commit a914049
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 20:34:41 2020 +0200

    feat: printError

commit 4a68045
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 19:14:14 2020 +0200

    feat: travis -> use spago

commit 8ef0769
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 19:09:15 2020 +0200

    feat: remove bower

commit 34d1fd8
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 19:09:07 2020 +0200

    feat: add spago

commit 42428e2
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 19:01:03 2020 +0200

    feat: update bower

commit 979439b
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 18:58:57 2020 +0200

    feat: update to argonaut 7 and affjax 11 -> run ps-suggest -> fix prev run

commit 5b58104
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 18:51:31 2020 +0200

    feat: update to argonaut 7 and affjax 11 -> run ps-suggest

commit 19df447
Author: Serhii Khoma <srghma@gmail.com>
Date:   Mon Nov 16 18:50:42 2020 +0200

    feat: update to argonaut 7 and affjax 11
@srghma
Copy link
Contributor Author

srghma commented Nov 19, 2020

done

@cryogenian cryogenian merged commit af9a883 into slamdata:master Nov 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants