Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep for 0.19: remove toString calls #2

Merged
merged 7 commits into from
Aug 22, 2018

Conversation

stoeffel
Copy link

@stoeffel stoeffel commented Aug 14, 2018

Looks like tests on our master are broken.

@stoeffel stoeffel requested a review from joneshf August 14, 2018 07:24
@stoeffel stoeffel force-pushed the 019-tostring-nri branch 3 times, most recently from 363c0e1 to 1d76e28 Compare August 14, 2018 07:37
Copy link

@joneshf joneshf left a comment

Choose a reason for hiding this comment

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

Wooo!!!

Had some questions about the char stuff, and I think a typo from a bad merge. Otherwise looks good.

If it's all good, feel free to merge without future review after the merge fix!

@@ -133,42 +148,46 @@ postPost body =
, withCredentials =
False
}
<<<<<<< HEAD
Copy link

Choose a reason for hiding this comment

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

Bad merge?

Copy link
Author

Choose a reason for hiding this comment

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

oops

isElmStringType opts elmTypeExpr =
elmTypeExpr `elem` stringElmTypes opts


toStringSrcTypes :: T.Text -> ElmOptions -> ElmDatatype -> T.Text
toStringSrcTypes operator opts (ElmPrimitive (EMaybe argType)) = toStringSrcTypes operator opts argType
toStringSrcTypes _ _ (ElmPrimitive (EList (ElmPrimitive EChar))) = "identity"
Copy link

Choose a reason for hiding this comment

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

It seems like this case would give a different type from the other cases, but I don't really understand how this function is supposed to work 😅. What does it do?

Copy link
Author

Choose a reason for hiding this comment

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

well document.

Copy link
Author

Choose a reason for hiding this comment

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

*will


{- | Determines whether we call `toString` on URL captures and query params of
this type in Elm.
-}
isElmStringType :: ElmOptions -> ElmDatatype -> Bool
isElmStringType _ (ElmPrimitive (EList (ElmPrimitive EChar))) = True
Copy link

Choose a reason for hiding this comment

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

Is this saying that an elm List Char is an elm String? If so, how does that work?

Copy link
Author

Choose a reason for hiding this comment

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

yes. don't know how it works, but it does 🙂

@@ -40,9 +40,16 @@ data ElmOptions = ElmOptions
-- ^ Types that represent an empty Http response.
, stringElmTypes :: [ElmDatatype]
-- ^ Types that represent a String.
, intElmTypes :: [ElmDatatype]
Copy link

Choose a reason for hiding this comment

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

Neat!

@stoeffel
Copy link
Author

waiting with merge until I get the integration tests green.

@stoeffel
Copy link
Author

tests are broken on master, because of the last two commits. I've fixed all the tests in here, but I had to add the orphan instance back. I didn't want to deal with that in this PR. happy to pair on removing that again in the future.
@joneshf would love another review.

Copy link

@joneshf joneshf left a comment

Choose a reason for hiding this comment

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

Sorry about breaking the tests.

Aside from the orphan stuff, everything looks good. Left some comments on it locally.


-- TODO: Generate Elm functions that can handle the response headers. PRs
-- welcome!
instance (ElmType a) => ElmType (Headers ls a) where
Copy link

Choose a reason for hiding this comment

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

I don't think we want to add this back.

We moved the instance to elm-export: NoRedInk/elm-export@4b68744.

If we add this back, we've no clue which instance ghc will chose when it decides to choose one. We can hope and pray that the two instances line up, but if one of them changes, we're really messed up when ghc decides which instance to choose.

I think we should drop this instance again and do one of the following:

  • Depend on our fork of elm-export.
    It doesn't look like our changes are going to be merged into upstream anytime soon, so no sense trying to keep parity with it. The tests will start compiling then.
  • Remove the test for Headers.
    If we can't support this data type, we shouldn't test against it.

No preference for either option, but I don't think re-adding this orphan is the way to go.

Copy link

Choose a reason for hiding this comment

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

Aside, this is a prime example of why working with these two dependencies has been frustrating for us. You start out wanting to make a seemingly innocuous change, and it ends up expanding into a whole web of problems.

Copy link
Author

Choose a reason for hiding this comment

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

thanks for the explanation and proposed solutions. will address asap.

Copy link
Author

Choose a reason for hiding this comment

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

@joneshf I removed the orphan and change the dependency to use our fork.

@joneshf
Copy link

joneshf commented Aug 22, 2018

Looks great!

@stoeffel stoeffel merged commit f69984f into NoRedInk:master Aug 22, 2018
@stoeffel stoeffel deleted the 019-tostring-nri branch August 22, 2018 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants