Skip to content

yi does not build with -XMonadFailDesugaring enabled (default in GHC 8.6+) #1102

Open

Description

@chessai

-XMonadFailDesugaring is enabled by default with GHC 8.6+. There are some failable patterns involving BufferM that cause Yi to fail to compile, because BufferM doesn't have a MonadFail instance.

Activity

  1. chessai commented on Nov 23, 2018

    @chessai
    Author

    Apologies for the fact that I forgot to copy the error I was getting the other day. There's likely more than one place, the easiest way to see all of them is either with GHC 8.6 or setting default-extensions: MonadFailDesugaring in your .cabal files

  2. changed the title [-]yi does not build with -XMonadFailDesugaring enabled[/-] [+]yi does not build with -XMonadFailDesugaring enabled (default in GHC 8.6+)[/+] on Nov 23, 2018
  3. zenhack commented on Nov 28, 2018

    @zenhack

    Just ran into this. I don't really have anything to add, except ftr this is the error output I got:

    [33 of 70] Compiling Yi.Buffer.Misc   ( src/Yi/Buffer/Misc.hs, dist/build/Yi/Buffer/Misc.o )
    
    src/Yi/Buffer/Misc.hs:453:25-95: error:
        • No instance for (Control.Monad.Fail.MonadFail BufferM)
            arising from a do statement
            with the failable pattern ‘Just mrks’
        • In a stmt of a 'do' block:
            Just mrks <- uses
                           winMarksA (M.lookup $ wkey (b ^. lastActiveWindowA))
          In the expression:
            do Just mrks <- uses
                              winMarksA (M.lookup $ wkey (b ^. lastActiveWindowA))
               forM mrks getMarkValueB
          In a stmt of a 'do' block:
            newMarkValues <- if wkey (b ^. lastActiveWindowA) == def then
                                 return
                                   MarkSet
                                     {insMark = MarkValue 0 Forward, selMark = MarkValue 0 Backward,
                                      fromMark = MarkValue 0 Backward}
                             else
                                 do Just mrks <- uses
                                                   winMarksA (M.lookup $ wkey (b ^. lastActiveWindowA))
                                    forM mrks getMarkValueB
        |
    453 |                         Just mrks  <- uses winMarksA (M.lookup $ wkey (b ^. lastActiveWindowA))
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Yi/Buffer/Misc.hs:873:3-30: error:
        • No instance for (Control.Monad.Fail.MonadFail BufferM)
            arising from a do statement
            with the failable pattern ‘Just !ms’
        • In a stmt of a 'do' block: Just !ms <- getMarks =<< ask
          In the expression:
            do Just !ms <- getMarks =<< ask
               return ms
          In an equation for ‘askMarks’:
              askMarks
                = do Just !ms <- getMarks =<< ask
                     return ms
        |
    873 |   Just !ms <- getMarks =<< ask
        |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cabal: Failed to build yi-core-0.18.0 (which is required by exe:yi from
    yi-0.18.0). See the build log above for details.
    
    
  4. xaverdh commented on Feb 17, 2019

    @xaverdh

    I have a quick and dirty (may eat your data) patch here: https://github.com/xaverdh/yi/commits/monad-fail
    Actually it probably won't eat your data.

  5. chessai commented on Feb 17, 2019

    @chessai
    Author

    Do we really want the possibility for 'error' to occur there? Is there not a way to just avoid the failable pattern?

  6. xaverdh commented on Feb 17, 2019

    @xaverdh

    Its not just failable patterns. printableChar for example calls fail explicitly.
    The implementation of MonadInteract also has an Fails constructor which deals with this.

  7. xaverdh commented on Feb 17, 2019

    @xaverdh

    Ah ok, you are probably referring to BufferM / EditorM. I don't know about that one.

  8. xaverdh commented on Feb 17, 2019

    @xaverdh

    Ok, its mostly about Marks. getMarks returns a Maybe value, but askMarks (which is used all over the place in that file) then discards it, so maybe its presence is/should be an invariant?
    runBufferFull looks like it should be, but then I don't understand why getMarks exists / is exported at all.

  9. xaverdh commented on Feb 17, 2019

    @xaverdh

    I opened a pull request #1108 based on a different branch, where I attempt to do things properly.
    We can discuss details there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions