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

MonadFail instance for GHC 8.6 #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Graphics/PDF/Draw.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ import Data.Maybe
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
#endif
#if MIN_VERSION_base(4,11,0)
import qualified Control.Monad.Fail as Fail
#endif

import qualified Data.Map.Strict as M
import qualified Data.IntMap as IM
Expand Down Expand Up @@ -186,6 +189,11 @@ instance Monad Draw where
unDraw (f a) env
return x = Draw $ \_env -> return x

#if MIN_VERSION_base(4,11,0)
instance Fail.MonadFail Draw where
fail s = Draw $ \_ -> Fail.fail s
Copy link

Choose a reason for hiding this comment

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

in my view this is the wrong way to go. the reason the original code was actually fine, was that the list is defined to be infinite, so that should be expressed by using, e.g., http://hackage.haskell.org/package/inflist-0.0.1/docs/src/Data-InfList.html#InfList

i've implemented that here: #27

#endif

instance MonadReader DrawEnvironment Draw where
ask = Draw $ \env -> return (drawEnvironment env)
local f m = Draw $ \env -> let drawenv' = f (drawEnvironment env)
Expand Down