Trying using Chart for learning Haskell. Package breaks in building with:
/private/var/folders/m2/qwhdrn_d46z99_3vxchdwn7r0000gn/T/stack5630/Chart-1.9/Graphics/Rendering/Chart/State.hs:102:3: error:
• No instance for (Control.Monad.Fail.MonadFail Identity)
arising from a do statement
with the failable pattern ‘(c : cs)’
• In a stmt of a 'do' block: (c : cs) <- use shapes
In the second argument of ‘($)’, namely
‘do (c : cs) <- use shapes
shapes .= cs
return c’
In the expression:
liftCState
$ do (c : cs) <- use shapes
shapes .= cs
return c
|
102 | (c:cs) <- use shapes
I am too inexperienced to know how to go about issues like this. Please advise.
You have some options to solve that problem. You are trying to do pattern matching in a 'do' block with non-exhaustive patterns. In order to do that:
You could disable the MonadFailDesugaring extension. Add {-# LANGUAGE NoMonadFailDesugaring #-} in the top of the file or compile with the flag -XNoMonadFailDesugaring. But this extension cannot be deactivated in GHC 8.8 ot later.
You could define or derive a MonadFail instance.
You could use the State monad. If a lower monad in the monad transformer stack is an instance of MonadFail, then we can make the highest monad an instance of MonadFail as well.
Desist, and perform explicit and exhaustive pattern matching.
source: http://www.fyrbll.me/haskell/language-extensions/monad-fail-desugaring/processed.html