diff --git a/benchmark/Main.hs b/benchmark/Main.hs index ee1fba7..9df5ec5 100644 --- a/benchmark/Main.hs +++ b/benchmark/Main.hs @@ -25,11 +25,10 @@ data Program = Program } parseBS :: ByteString -> IO BFProgram -parseBS = - either (throwIO . userError . show) pure - . parseBF - . unpack - . decodeUtf8With lenientDecode +parseBS = throwIfLeft . parseBF . unpack . decodeUtf8With lenientDecode + where + throwIfLeft (Left e) = throwIO . userError . show $ e + throwIfLeft (Right v) = pure v brainfuckFiles :: [(FilePath, ByteString)] brainfuckFiles = filter isBrainfuckFile files diff --git a/src/Language/BrainHask/Optimizer.hs b/src/Language/BrainHask/Optimizer.hs index 468f7b1..318bf78 100644 --- a/src/Language/BrainHask/Optimizer.hs +++ b/src/Language/BrainHask/Optimizer.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} module Language.BrainHask.Optimizer (optimize, OptimizationLevel (..)) where diff --git a/src/Language/BrainHask/Preprocessor.hs b/src/Language/BrainHask/Preprocessor.hs index 4255f08..dd93657 100644 --- a/src/Language/BrainHask/Preprocessor.hs +++ b/src/Language/BrainHask/Preprocessor.hs @@ -1,8 +1,8 @@ module Language.BrainHask.Preprocessor (preprocess) where +import Data.Functor (($>)) import Data.Transformer import Language.BrainHask.Types -import Data.Functor (($>)) type Preprocessor a = Transformer BFOp (ILOp Int a)