Implement NoStarIsType and MonadFail for GHC 8.6.

This commit is contained in:
Kevin Quick 2018-11-21 00:08:33 +00:00
parent 7a64cb614f
commit 1d7cdc87eb
No known key found for this signature in database
GPG Key ID: E6D7733599CC0A21
3 changed files with 7 additions and 1 deletions

View File

@ -46,6 +46,8 @@ library
ghc-options: -Wall ghc-options: -Wall
ghc-options: -fno-warn-unticked-promoted-constructors ghc-options: -fno-warn-unticked-promoted-constructors
ghc-prof-options: -O2 -fprof-auto-top ghc-prof-options: -O2 -fprof-auto-top
if impl(ghc >= 8.6)
default-extensions: NoStarIsType
test-suite macaw-x86-tests test-suite macaw-x86-tests
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0

View File

@ -38,6 +38,7 @@ module Data.Macaw.X86.ArchTypes
) where ) where
import Data.Bits import Data.Bits
import qualified Data.Kind as Kind
import Data.Word(Word8) import Data.Word(Word8)
import Data.Macaw.CFG import Data.Macaw.CFG
import Data.Macaw.CFG.Rewriter import Data.Macaw.CFG.Rewriter
@ -877,7 +878,7 @@ x86PrimFnHasSideEffects f =
-- X86Stmt -- X86Stmt
-- | An X86 specific statement. -- | An X86 specific statement.
data X86Stmt (v :: Type -> *) where data X86Stmt (v :: Type -> Kind.Type) where
WriteLoc :: !(X86PrimLoc tp) -> !(v tp) -> X86Stmt v WriteLoc :: !(X86PrimLoc tp) -> !(v tp) -> X86Stmt v
-- | Store the X87 control register in the given address. -- | Store the X87 control register in the given address.

View File

@ -61,6 +61,7 @@ module Data.Macaw.X86.Generator
import Control.Lens import Control.Lens
import Control.Monad.Cont import Control.Monad.Cont
import Control.Monad.Except import Control.Monad.Except
import Control.Monad.Fail
import Control.Monad.Reader import Control.Monad.Reader
import Control.Monad.ST import Control.Monad.ST
import Control.Monad.State.Strict import Control.Monad.State.Strict
@ -267,6 +268,8 @@ instance Monad (X86Generator st_s ids) where
return v = seq v $ X86G $ return v return v = seq v $ X86G $ return v
(X86G m) >>= h = X86G $ m >>= \v -> seq v (unX86G (h v)) (X86G m) >>= h = X86G $ m >>= \v -> seq v (unX86G (h v))
X86G m >> X86G n = X86G $ m >> n X86G m >> X86G n = X86G $ m >> n
instance MonadFail (X86Generator st_s ids) where
fail msg = seq t $ X86G $ ContT $ \_ -> throwError t fail msg = seq t $ X86G $ ContT $ \_ -> throwError t
where t = Text.pack msg where t = Text.pack msg