summaryrefslogtreecommitdiff
path: root/lore/Language/Bs/Primitives.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-03-27 22:58:53 -0700
committerBen Sima <ben@bsima.me>2019-03-27 22:58:53 -0700
commit4ecc513e5917057f50150e2cb0a1d63d6010f0d7 (patch)
treede711731ad4dc430e057774d06c200c4f497a509 /lore/Language/Bs/Primitives.hs
parent285e1eefe19ac6865bf0ebab388456f23fb480a9 (diff)
bs: add protolude and organize imports
Diffstat (limited to 'lore/Language/Bs/Primitives.hs')
-rw-r--r--lore/Language/Bs/Primitives.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/lore/Language/Bs/Primitives.hs b/lore/Language/Bs/Primitives.hs
index 2c90164..6042b82 100644
--- a/lore/Language/Bs/Primitives.hs
+++ b/lore/Language/Bs/Primitives.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE NoImplicitPrelude #-}
-- | bs primitives
--
-- I would like to reduce the number of primitives in the language to some
@@ -13,6 +14,7 @@ import Data.Text as T
import Data.Text.IO as TIO
import Language.Bs.Expr
import Network.HTTP
+import Protolude
import System.Directory
import System.IO
@@ -51,7 +53,7 @@ primEnv = [
, ("file?" , mkF $ unop fileExists)
, ("slurp" , mkF $ unop slurp)
, ("wslurp" , mkF $ unop wSlurp)
- , ("put" , mkF $ binop put)
+ , ("put" , mkF $ binop put_)
]
unop :: Unary -> [Expr] -> Eval Expr
@@ -91,10 +93,10 @@ readTextFile fileName handle = do
then (TIO.hGetContents handle) >>= (return . Tape)
else throw $ ReadFileError $ T.concat [" file does not exist: ", fileName]
-put :: Expr -> Expr -> Eval Expr
-put (Tape file) (Tape msg) = liftIO $ wFilePut file msg
-put (Tape _) val = throw $ TypeMismatch "put expects string in the second argument (try using show), instead got: " val
-put val _ = throw $ TypeMismatch "put expects string, instead got: " val
+put_ :: Expr -> Expr -> Eval Expr
+put_ (Tape file) (Tape msg) = liftIO $ wFilePut file msg
+put_ (Tape _) val = throw $ TypeMismatch "put expects string in the second argument (try using show), instead got: " val
+put_ val _ = throw $ TypeMismatch "put expects string, instead got: " val
wFilePut :: T.Text -> T.Text -> IO Expr
wFilePut fileName msg = withFile (T.unpack fileName) WriteMode go