isovector / do-notation

deprecated in favor of -XQualifiedDo
BSD 3-Clause "New" or "Revised" License
41 stars 5 forks source link

BindSyntax and mtl-style #3

Open redxaxder opened 5 years ago

redxaxder commented 5 years ago

In the following example the selected BindSyntax instance is the one with aIxMonad constraint rather than the one with a Monad constraint.

{-# LANGUAGE RebindableSyntax #-}
module Scratch where

import   Language.Haskell.DoNotation
import   Prelude   hiding (Monad (..),   pure)
import   Control.Monad.Writer.Class (MonadWriter, tell)

tell2 :: MonadWriter w m => w -> m ()
tell2 x = tell x >> tell x

{-
    • Couldn't match type ‘m’ with ‘m0 i0 k20’
        arising from a use of ‘>>’
      ‘m’ is a rigid type variable bound by
        the type signature for:
          tell2 :: forall w (m :: * -> *). MonadWriter w m => w -> m ()
        at src/Scratch.hs:9:1-37
    • In the expression: tell x >> tell x
      In an equation for ‘tell2’: tell2 x = tell x >> tell x
    • Relevant bindings include
        tell2 :: w -> m () (bound at src/Scratch.hs:10:1)
-}

I think most mtl-style code won't compile with this syntax change.

isovector commented 5 years ago

Yikes! I don't have time to dig into this right now, but I wonder if https://github.com/isovector/do-notation/pull/2 fixes the problem. Mind giving it a try?