Replacing $
operator with more readable |>
operator
This commit is contained in:
parent
2b1c486c17
commit
0792bf3c7d
12 changed files with 122 additions and 101 deletions
14
hs/Fetch.hs
14
hs/Fetch.hs
|
@ -18,30 +18,32 @@ import BusTypes(
|
|||
BusVal(..),
|
||||
BusError(..))
|
||||
import Exceptions(Exception(..))
|
||||
import Util((|>))
|
||||
|
||||
data FetchResult = Instruction Insn
|
||||
| InstructionException Exception
|
||||
deriving (Generic, Show, Eq, NFDataX)
|
||||
|
||||
|
||||
fetchInstruction :: Peripherals -> Addr -> IO FetchResult
|
||||
fetchInstruction peripherals addr =
|
||||
do
|
||||
readReasponse <-Bus.read (BusTypes.Request addr BusTypes.SizeFullWord) peripherals
|
||||
case readReasponse of
|
||||
Right (BusFullWord insn) ->
|
||||
pure $ Instruction insn
|
||||
pure |> Instruction insn
|
||||
Left UnAligned ->
|
||||
pure $ InstructionException (InstructionAddressMisaligned addr)
|
||||
pure |> InstructionException (InstructionAddressMisaligned addr)
|
||||
Left UnMapped ->
|
||||
pure $ InstructionException (InstructionAccessFault addr)
|
||||
pure |> InstructionException (InstructionAccessFault addr)
|
||||
Right _ ->
|
||||
pure $ InstructionException (InstructionAccessFault addr)
|
||||
pure |> InstructionException (InstructionAccessFault addr)
|
||||
|
||||
debugInsn :: FetchResult -> String
|
||||
debugInsn fetchResult =
|
||||
debugInsn fetchResult =
|
||||
case fetchResult of
|
||||
Instruction insn ->
|
||||
"Instruction raw binary | "
|
||||
"Instruction raw binary | "
|
||||
P.++ binaryInsn
|
||||
P.++ " (" P.++ show insn P.++ ")"
|
||||
where
|
||||
|
|
Reference in a new issue