Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Replace Asterius.Internals.IO with GHC.Types.IO (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkaracha authored Mar 28, 2020
1 parent 8c673de commit e90382f
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 36 deletions.
1 change: 0 additions & 1 deletion asterius/app/ahc-dist.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Asterius.Internals
import Asterius.Main
import Prelude hiding (IO)

main :: IO ()
main = do
Expand Down
2 changes: 0 additions & 2 deletions asterius/src/Asterius/Ar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ module Asterius.Ar
where

import qualified Ar as GHC
import Asterius.Internals
import Asterius.Internals.Binary
import Asterius.Types
import Control.Exception
import Data.List
import Prelude hiding (IO)

loadAr :: FilePath -> IO AsteriusModule
loadAr p = do
Expand Down
1 change: 0 additions & 1 deletion asterius/src/Asterius/Backends/Binaryen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import Foreign hiding
import Foreign.C
import GHC.Exts
import Language.Haskell.GHC.Toolkit.Constants
import Prelude hiding (IO)

newtype MarshalError
= UnsupportedExpression Expression
Expand Down
3 changes: 1 addition & 2 deletions asterius/src/Asterius/Boot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ import System.Directory
import System.Environment
import System.Exit
import System.FilePath
import System.IO hiding (IO)
import System.IO
import System.Process
import Prelude hiding (IO)

data BootArgs
= BootArgs
Expand Down
4 changes: 0 additions & 4 deletions asterius/src/Asterius/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ import Asterius.Internals.MagicNumber
import Asterius.Types
import qualified Data.ByteString.Short as SBS
import Data.Foldable
import Data.Functor
import Data.List
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.String
import Data.Word
import qualified GhcPlugins as GHC
import Language.Haskell.GHC.Toolkit.Constants
import Prelude hiding (IO)

wasmPageSize :: Int
wasmPageSize = 65536
Expand Down
6 changes: 2 additions & 4 deletions asterius/src/Asterius/CodeGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ import Language.Haskell.GHC.Toolkit.Orphans.Show
import Stream (Stream)
import qualified Stream
import qualified Unique as GHC
import Prelude hiding (IO)
import qualified Prelude

type CodeGenContext = (GHC.DynFlags, String)

newtype CodeGen a
= CodeGen (ReaderT CodeGenContext Prelude.IO a)
= CodeGen (ReaderT CodeGenContext IO a)
deriving (Functor, Applicative, Monad, MonadReader CodeGenContext, MonadIO)

unCodeGen :: CodeGen a -> CodeGen (Either AsteriusCodeGenError a)
Expand Down Expand Up @@ -1513,7 +1511,7 @@ marshalCmmIR this_mod CmmIR {..} = marshalRawCmm this_mod cmmRaw

marshalRawCmm ::
GHC.Module ->
Stream Prelude.IO GHC.RawCmmGroup () ->
Stream IO GHC.RawCmmGroup () ->
CodeGen AsteriusModule
marshalRawCmm _ = w mempty
where
Expand Down
6 changes: 1 addition & 5 deletions asterius/src/Asterius/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
{-# LANGUAGE UnboxedTuples #-}

module Asterius.Internals
( IO,
encodeStorable,
( encodeStorable,
reinterpretCast,
encodeFile,
decodeFile,
Expand All @@ -25,9 +24,6 @@ import Foreign
import GHC.Exts
import GHC.Stack
import qualified GHC.Types
import Prelude hiding (IO)

type IO a = HasCallStack => GHC.Types.IO a

unI# :: Int -> Int#
unI# (I# x) = x
Expand Down
7 changes: 1 addition & 6 deletions asterius/src/Asterius/JSFFI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ import Asterius.Types
import qualified CmmCallConv as GHC
import qualified CmmExpr as GHC
import qualified CmmNode as GHC
import Control.Applicative
import Data.ByteString.Builder
import Data.Coerce
import Data.IORef
import Data.Int
import Data.List
import qualified Data.Map.Strict as M
import Data.Monoid
import qualified GhcPlugins as GHC
import Language.Haskell.GHC.Toolkit.Constants
import Prelude hiding (IO)
import qualified Prelude

recoverWasmWrapperValueType :: FFIValueType -> ValueType
recoverWasmWrapperValueType FFIValueType {..} = case ffiValueTypeRep of
Expand Down Expand Up @@ -72,7 +67,7 @@ recoverWasmWrapperFunctionType ffi_safety FFIFunctionType {..}
ret_types = map recoverWasmWrapperValueType ffiResultTypes

getFFIModule ::
GHC.DynFlags -> AsteriusModuleSymbol -> Prelude.IO AsteriusModule
GHC.DynFlags -> AsteriusModuleSymbol -> IO AsteriusModule
getFFIModule dflags mod_sym = do
ffi_import_state <-
atomicModifyIORef' globalFFIHookState $ \ffi_hook_state ->
Expand Down
1 change: 0 additions & 1 deletion asterius/src/Asterius/Ld.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Data.Either
import qualified Data.Set as Set
import Data.Set (Set)
import Data.Traversable
import Prelude hiding (IO)

data LinkTask
= LinkTask
Expand Down
4 changes: 1 addition & 3 deletions asterius/src/Asterius/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import qualified Data.ByteString.Unsafe as BS
import Data.Foldable
import Data.List
import qualified Data.Map.Strict as M
import Data.Maybe
import qualified Data.Set as S
import Data.String
import Foreign
Expand All @@ -53,9 +52,8 @@ import System.Console.GetOpt
import System.Directory
import System.Environment.Blank
import System.FilePath
import System.IO hiding (IO)
import System.IO
import System.Process
import Prelude hiding (IO)

parseTask :: [String] -> Task
parseTask args = case err_msgs of
Expand Down
1 change: 0 additions & 1 deletion asterius/src/Asterius/Resolve.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Foreign
import GHC.Generics
import Language.Haskell.GHC.Toolkit.Constants
import Unsafe.Coerce
import Prelude hiding (IO)

unresolvedGlobalRegType :: UnresolvedGlobalReg -> ValueType
unresolvedGlobalRegType gr = case gr of
Expand Down
2 changes: 0 additions & 2 deletions asterius/src/Asterius/TypesConv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Asterius.TypesConv
)
where

import Asterius.Internals
import Asterius.Types
import qualified Data.ByteString.Char8 as CBS
import qualified Data.ByteString.Short as SBS
Expand All @@ -24,7 +23,6 @@ import System.IO
( IOMode (WriteMode),
withFile,
)
import Prelude hiding (IO)

{-# INLINE marshalToModuleSymbol #-}
marshalToModuleSymbol :: GHC.Module -> AsteriusModuleSymbol
Expand Down
6 changes: 2 additions & 4 deletions asterius/test/node-compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ import qualified Language.WebAssembly.WireFormat as Wasm
import System.Directory
import System.Exit
import System.FilePath
import System.IO hiding (IO)
import System.IO
import System.Process
import Test.QuickCheck
import Test.QuickCheck.Monadic
import Prelude hiding (IO)
import qualified Prelude

type Shrink a = a -> FList.FList a

Expand Down Expand Up @@ -160,7 +158,7 @@ shrinkModule' m@Module {..} = _shrink_funcs {-_shrink_memory <> _shrink_exports
shrinkModule :: Module -> [Module]
shrinkModule = toList . shrinkModule'

type Backend = (String, Module -> Prelude.IO LBS.ByteString)
type Backend = (String, Module -> IO LBS.ByteString)

binaryenBackend, wasmToolkitBackend :: Backend
binaryenBackend =
Expand Down

0 comments on commit e90382f

Please sign in to comment.