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

Provide updateActionModify API in AutoUpdate #547

Merged
merged 5 commits into from
May 9, 2016

Conversation

nanonaren
Copy link
Contributor

Fixes #535

@snoyberg
Copy link
Member

snoyberg commented May 4, 2016

Travis builds failed due to (at least) missing imports.

@nanonaren
Copy link
Contributor Author

How did that happen? Why would it compile for me?

@snoyberg
Copy link
Member

snoyberg commented May 4, 2016

You're probably using a newer version of GHC.

On Wed, May 4, 2016, 2:11 PM Naren Sundar notifications@github.com wrote:

How did that happen? Why would it compile for me?


You are receiving this because you commented.

Reply to this email directly or view it on GitHub
#547 (comment)

@nanonaren
Copy link
Contributor Author

Right. I am using 7.10.3 and the Travis build doesn't show the missing import for <*> in that version but does in 7.8.4 and 7.6.3. How do I fix this?

@nanonaren
Copy link
Contributor Author

I guess I'll just not use <*>. Probably the simplest thing to do.

@snoyberg
Copy link
Member

snoyberg commented May 4, 2016

By adding the missing import statement.

On Wed, May 4, 2016, 2:18 PM Naren Sundar notifications@github.com wrote:

Right. I am using 7.10.3 and the Travis build doesn't show the missing
import for <*> in that version but does in 7.8.4 and 7.6.3. How do I fix
this?


You are receiving this because you commented.

Reply to this email directly or view it on GitHub
#547 (comment)

@nanonaren
Copy link
Contributor Author

Adding the import statement raises the complaint

/home/narens/Documents/wai/auto-update/Control/AutoUpdate.hs:42:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()

Is that okay?

@snoyberg
Copy link
Member

snoyberg commented May 4, 2016

It's OK. The usual solution is to use CPP to make the import conditional.

On Wed, May 4, 2016, 2:23 PM Naren Sundar notifications@github.com wrote:

Adding the import statement raises the complaint

/home/narens/Documents/wai/auto-update/Control/AutoUpdate.hs:42:1: Warning:
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()

Is that okay?


You are receiving this because you commented.

Reply to this email directly or view it on GitHub
#547 (comment)

@nanonaren
Copy link
Contributor Author

Sorry, I could only find one example of #ifdef GHC_7_4 in the code. Would this be fine

#ifndef GHC_7_10
import           Control.Applicative     ((<*>))
#endif

@snoyberg
Copy link
Member

snoyberg commented May 4, 2016

I'm on my phone right now so I can't find an example myself, but there
should be lots of usages of MIN_VERSION scattered around

On Wed, May 4, 2016, 2:29 PM Naren Sundar notifications@github.com wrote:

Sorry, I could only find one example of #ifdef GHC_7_4 in the code. Would
this be fine

#ifndef GHC_7_10
import Control.Applicative ((<*>))
#endif


You are receiving this because you commented.

Reply to this email directly or view it on GitHub
#547 (comment)

@@ -90,6 +92,11 @@ data UpdateSettings a = UpdateSettings
-- Default: does nothing.
--
-- @since 0.1.0
, updateActionModify :: Maybe (a -> IO a)
-- ^ Optional action to be performed to get the current value
-- and updating it if necessary.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence switches tense—I think you want "to get the current value and update it if necessary."

@MaxGabriel
Copy link
Member

Looks like there are some auto-update related compiler errors in the latest Travis results, btw: https://travis-ci.org/yesodweb/wai/jobs/127737868

@nanonaren
Copy link
Contributor Author

It looks like this change cannot be made without breaking the API. So, this error

Network/Wai/Handler/Warp/Date.hs:31:27:

    Couldn't match type ‘()’ with ‘ByteString’

    Expected type: Control.AutoUpdate.UpdateSettings GMTDate

      Actual type: Control.AutoUpdate.UpdateSettings ()

    In the expression: defaultUpdateSettings

    In the first argument of ‘mkAutoUpdate’, namely

      ‘defaultUpdateSettings

         {updateAction = formatHTTPDate <$> getCurrentHTTPDate}’

happens because in the use above updateAction is updated to the type IO GMTDate but updateActionModify remains unchanged. It will have to be explicitly set.

@snoyberg
Copy link
Member

snoyberg commented May 5, 2016

That's unfortunate. I don't see a way of making this happen then.

@snoyberg
Copy link
Member

snoyberg commented May 5, 2016

There's another approach that could be taken I think: add a new function mkAutoUpdateWithModify that takes the modification value as a separate argument.

@MaxGabriel
Copy link
Member

I think this is good to merge I think

@snoyberg snoyberg merged commit d895b71 into yesodweb:master May 9, 2016
@snoyberg
Copy link
Member

snoyberg commented May 9, 2016

Thanks!

snoyberg added a commit that referenced this pull request May 9, 2016
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.

None yet

3 participants