Skip to content

Fix GHC 8.0.2 build (and fix #2421)#2422

Merged
paf31 merged 2 commits into
purescript:masterfrom
RyanGlScott:master
Nov 9, 2016
Merged

Fix GHC 8.0.2 build (and fix #2421)#2422
paf31 merged 2 commits into
purescript:masterfrom
RyanGlScott:master

Conversation

@RyanGlScott

@RyanGlScott RyanGlScott commented Nov 8, 2016

Copy link
Copy Markdown
Contributor

As noted in #2421, the default type signatures for fresh and peek are bogus, and GHC 8.0.2's reworked DefaultSignatures typechecking now complains about them. To rectify this, I replaced them with better type signatures.

Fixes #2421.

@paf31

paf31 commented Nov 9, 2016

Copy link
Copy Markdown
Contributor

Thanks! But why not (MonadTrans t, MonadSupply m) => t m Integer?

@paf31

paf31 commented Nov 9, 2016

Copy link
Copy Markdown
Contributor

Also, can you please update contributors.md.

@RyanGlScott

Copy link
Copy Markdown
Contributor Author

But why not (MonadTrans t, MonadSupply m) => t m Integer?

Because that won't typecheck. If you try it, you'll get this:

[ 20 of 139] Compiling Control.Monad.Supply.Class ( src/Control/Monad/Supply/Class.hs, dist/build/Control/Monad/Supply/Class.o )

src/Control/Monad/Supply/Class.hs:31:10: error:
    • Couldn't match type ‘m’ with ‘StateT s m’
      ‘m’ is a rigid type variable bound by
        the instance declaration at src/Control/Monad/Supply/Class.hs:31:10
      Expected type: StateT s m Integer
        Actual type: StateT s (StateT s m) Integer
    • In the expression:
        Control.Monad.Supply.Class.$dmfresh @StateT s m
      In an equation for ‘fresh’:
          fresh = Control.Monad.Supply.Class.$dmfresh @StateT s m
      In the instance declaration for ‘MonadSupply (StateT s m)’
    • Relevant bindings include
        fresh :: StateT s m Integer
          (bound at src/Control/Monad/Supply/Class.hs:31:10)

src/Control/Monad/Supply/Class.hs:31:10: error:
    • Couldn't match type ‘m’ with ‘StateT s m’
      ‘m’ is a rigid type variable bound by
        the instance declaration at src/Control/Monad/Supply/Class.hs:31:10
      Expected type: StateT s m Integer
        Actual type: StateT s (StateT s m) Integer
    • In the expression: Control.Monad.Supply.Class.$dmpeek @StateT s m
      In an equation for ‘peek’:
          peek = Control.Monad.Supply.Class.$dmpeek @StateT s m
      In the instance declaration for ‘MonadSupply (StateT s m)’
    • Relevant bindings include
        peek :: StateT s m Integer
          (bound at src/Control/Monad/Supply/Class.hs:31:10)

The issue with that code is that m is bound separately by the class definition for MonadSupply, and you're not allowed to equate it with the smaller type in the default type signature that happens to be a MonadSupply instance itself. (Another way of thinking of it is that you're trying to unify m ~ t m, which would trip the occurs check!)

Also, can you please update contributors.md.

Done.

@paf31

paf31 commented Nov 9, 2016

Copy link
Copy Markdown
Contributor

Oh, I see. I think I misunderstood something about the way in which DefaultSignatures works. Thanks!

@paf31 paf31 merged commit 46f573a into purescript:master Nov 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.

2 participants