shithub: MicroHs

Download patch

ref: f5b1f536ad9d78e690c09bbfcb2438631f6958a9
parent: 91d5c871f7184389e822907e45e3be2fab2ef3b1
author: Lennart Augustsson <lennart@augustsson.net>
date: Sat Aug 26 08:25:51 EDT 2023

Add FilePath.

--- a/lib/System/IO.hs
+++ b/lib/System/IO.hs
@@ -13,6 +13,8 @@
 --Ytype IO = P.IO
 --Ytype Handle = P.Handle
 
+type FilePath = String
+
 data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode
 
 --Yinfixl 1 >>=
@@ -49,7 +51,7 @@
 hPutChar :: Handle -> Char -> IO ()
 hPutChar h c = P.primHPutChar h (ord c)
 
-openFileM :: String -> IOMode -> IO (Maybe Handle)
+openFileM :: FilePath -> IOMode -> IO (Maybe Handle)
 openFileM p m = do
   let {
     n = case m of
@@ -117,7 +119,7 @@
 hPutStrLn :: Handle -> String -> IO ()
 hPutStrLn h s = hPutStr h s >> hPutChar h '\n'
 
-writeFile :: String -> String -> IO ()
+writeFile :: FilePath -> String -> IO ()
 writeFile p s = do
   h <- openFile p WriteMode
   hPutStr h s
@@ -124,7 +126,7 @@
   hClose h
 
 -- Strict readFile
-readFile :: String -> IO String
+readFile :: FilePath -> IO String
 readFile p = do
   h <- openFile p ReadMode
   cs <- hGetContents h
--- a/src/MicroHs/Compile.hs
+++ b/src/MicroHs/Compile.hs
@@ -120,12 +120,12 @@
 
 ------------------
 
-readFilePath :: [String] -> String -> IO String
+readFilePath :: [FilePath] -> FilePath -> IO String
 readFilePath path name = IO.do
   h <- openFilePath path name
   IO.hGetContents h
 
-openFilePath :: [String] -> String -> IO Handle
+openFilePath :: [FilePath] -> FilePath -> IO Handle
 openFilePath adirs fileName =
   case adirs of
     [] -> error $ "File not found: " ++ showString fileName
--- a/src/Text/ParserComb.hs
+++ b/src/Text/ParserComb.hs
@@ -1,8 +1,6 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
 {-# OPTIONS_GHC -Wno-type-defaults #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
 module Text.ParserComb(
   (>>=), (>>), pure,
   (<*), (*>), (<*>), (<$), (<$>),
--