git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'master' into pure11
commit9264ef481b0439747ae56a7febf0e83fc4f07d3d authorAndy Arvanitis <andyarvanitis@gmail.com> dateSat 21 Nov 2015, 15:59 (11 years ago) parent4e144cef36f1d5
20 files changed+106−55
CONTRIBUTORS.md+1 bundle/.gitignore+1 examples/passing/UnicodeIdentifier.purs+5 psci/PSCi.hs+1−1 psci/Parser.hs+3−1 src/Language/PureScript/AST/Declarations.hs+2−1 src/Language/PureScript/CoreFn/Desugar.hs+6−2 src/Language/PureScript/Docs/ParseAndDesugar.hs+2−2 src/Language/PureScript/Errors.hs+34−8 src/Language/PureScript/Externs.hs+1−1 src/Language/PureScript/Make.hs+14−12 src/Language/PureScript/ModuleDependencies.hs+1−1 src/Language/PureScript/Parser/Declarations.hs+7−14 src/Language/PureScript/Pretty/Types.hs+1−1 src/Language/PureScript/Sugar/Names.hs+1−1 src/Language/PureScript/Sugar/Names/Exports.hs+1−1 src/Language/PureScript/Sugar/Names/Imports.hs+3−2 src/Language/PureScript/TypeChecker/Types.hs+1−2 src/Language/PureScript/TypeChecker/Unify.hs+1−1 src/System/IO/UTF8.hs+20−4
CONTRIBUTORS.md+1
@@ -26,6 +26,7 @@ This file lists the contributors to the PureScript compiler project, and the ter
2626- [@joneshf](https://github.com/joneshf) (Hardy Jones) - My existing contributions and all future contributions until further notice are Copyright Hardy Jones, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license.
2727- [@kRITZCREEK](https://github.com/kRITZCREEK) (Christoph Hegemann) - My existing contributions and all future contributions until further notice are Copyright Christoph Hegemann, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license.
2828- [@L8D](https://github.com/L8D) (Tenor Biel) My existing contributions and all future contributions until further notice are Copyright Tenor Biel, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
29+- [@leighman](http://github.com/leighman) (Jack Leigh) My existing contributions and all future contributions until further notice are Copyright Jack Leigh, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
2930- [@lukerandall](https://github.com/lukerandall) (Luke Randall) My existing contributions and all future contributions until further notice are Copyright Luke Randall, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
3031- [@michaelficarra](https://github.com/michaelficarra) (Michael Ficarra) My existing contributions and all future contributions until further notice are Copyright Michael Ficarra, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
3132- [@MichaelXavier](https://github.com/MichaelXavier) (Michael Xavier) - My existing contributions and all future contributions until further notice are Copyright Michael Xavier, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license.
bundle/.gitignore+1
@@ -1,3 +1,4 @@
11build/
22*.tar.gz
33*.sha
4+*.md5
examples/passing/UnicodeIdentifier.pursnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+f asgård = asgård
4+
5+main = Control.Monad.Eff.Console.log (f "Done")
psci/PSCi.hs+1−1
@@ -242,7 +242,7 @@ createTemporaryModuleForImports PSCiState{psciImportedModules = imports} =
242242 P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName (importDecl `map` imports) Nothing
243243
244244importDecl :: ImportedModule -> P.Declaration
245−importDecl (mn, declType, asQ) = P.ImportDeclaration mn declType asQ
245+importDecl (mn, declType, asQ) = P.ImportDeclaration mn declType asQ False
246246
247247indexFile :: FilePath
248248indexFile = ".psci_modules" ++ pathSeparator : "index.js"
psci/Parser.hs+3−1
@@ -106,7 +106,9 @@ psciLet = Decls <$> (P.reserved "let" *> P.indented *> manyDecls)
106106-- | Imports must be handled separately from other declarations, so that
107107-- :show import works, for example.
108108psciImport :: P.TokenParser Command
109−psciImport = Import <$> P.parseImportDeclaration'
109+psciImport = do
110+ (mn, declType, asQ, _) <- P.parseImportDeclaration'
111+ return $ Import (mn, declType, asQ)
110112
111113-- | Any other declaration that we don't need a 'special case' parser for
112114-- (like let or import declarations).
src/Language/PureScript/AST/Declarations.hs+2−1
@@ -153,8 +153,9 @@ data Declaration
153153 | FixityDeclaration Fixity String
154154 -- |
155155 -- A module import (module name, qualified/unqualified/hiding, optional "qualified as" name)
156+ -- TODO: also a boolean specifying whether the old `qualified` syntax was used, so a warning can be raised in desugaring (remove for 0.9)
156157 --
157− | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName)
158+ | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName) Bool
158159 -- |
159160 -- A type class declaration (name, argument, implies, member declarations)
160161 --
src/Language/PureScript/CoreFn/Desugar.hs+6−2
@@ -203,9 +203,13 @@ moduleToCoreFn env (A.Module _ coms mn decls (Just exps)) =
203203--
204204findQualModules :: [A.Declaration] -> [ModuleName]
205205findQualModules decls =
206− let (f, _, _, _, _) = everythingOnValues (++) (const []) fqValues fqBinders (const []) (const [])
206+ let (f, _, _, _, _) = everythingOnValues (++) fqDecls fqValues fqBinders (const []) (const [])
207207 in f `concatMap` decls
208208 where
209+ fqDecls :: A.Declaration -> [ModuleName]
210+ fqDecls (A.TypeInstanceDeclaration _ _ (Qualified (Just mn) _) _ _) = [mn]
211+ fqDecls _ = []
212+
209213 fqValues :: A.Expr -> [ModuleName]
210214 fqValues (A.Var (Qualified (Just mn) _)) = [mn]
211215 fqValues (A.Constructor (Qualified (Just mn) _)) = [mn]
@@ -219,7 +223,7 @@ findQualModules decls =
219223-- Desugars import declarations from AST to CoreFn representation.
220224--
221225importToCoreFn :: A.Declaration -> Maybe ModuleName
222−importToCoreFn (A.ImportDeclaration name _ _) = Just name
226+importToCoreFn (A.ImportDeclaration name _ _ _) = Just name
223227importToCoreFn (A.PositionedDeclaration _ _ d) = importToCoreFn d
224228importToCoreFn _ = Nothing
225229
src/Language/PureScript/Docs/ParseAndDesugar.hs+2−2
@@ -108,9 +108,9 @@ fileInfoToString (FromDep _ fn) = fn
108108addDefaultImport :: P.ModuleName -> P.Module -> P.Module
109109addDefaultImport toImport m@(P.Module ss coms mn decls exps) =
110110 if isExistingImport `any` decls || mn == toImport then m
111− else P.Module ss coms mn (P.ImportDeclaration toImport P.Implicit Nothing : decls) exps
111+ else P.Module ss coms mn (P.ImportDeclaration toImport P.Implicit Nothing False : decls) exps
112112 where
113− isExistingImport (P.ImportDeclaration mn' _ _) | mn' == toImport = True
113+ isExistingImport (P.ImportDeclaration mn' _ _ _) | mn' == toImport = True
114114 isExistingImport (P.PositionedDeclaration _ _ d) = isExistingImport d
115115 isExistingImport _ = False
116116
src/Language/PureScript/Errors.hs+34−8
@@ -21,8 +21,9 @@ module Language.PureScript.Errors where
2121import Prelude ()
2222import Prelude.Compat
2323
24+import Data.Ord (comparing)
2425import Data.Either (lefts, rights)
25−import Data.List (intercalate, transpose, nub, nubBy)
26+import Data.List (intercalate, transpose, nub, nubBy, sortBy)
2627import Data.Function (on)
2728import Data.Foldable (fold)
2829
@@ -32,7 +33,7 @@ import Control.Monad
3233import Control.Monad.Writer
3334import Control.Monad.Error.Class (MonadError(..))
3435import Control.Monad.Trans.State.Lazy
35−import Control.Arrow (first)
36+import Control.Arrow (first, (&&&))
3637
3738import Language.PureScript.Crash
3839import Language.PureScript.AST
@@ -141,6 +142,7 @@ data SimpleErrorMessage
141142 | UnusedExplicitImport ModuleName [String]
142143 | UnusedDctorImport ProperName
143144 | UnusedDctorExplicitImport ProperName [ProperName]
145+ | DeprecatedQualifiedSyntax ModuleName ModuleName
144146 deriving (Show)
145147
146148-- | Error message hints, providing more detailed information about failure.
@@ -275,6 +277,7 @@ errorCode em = case unwrapErrorMessage em of
275277 UnusedExplicitImport{} -> "UnusedExplicitImport"
276278 UnusedDctorImport{} -> "UnusedDctorImport"
277279 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
280+ DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
278281
279282
280283-- |
@@ -520,12 +523,31 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
520523 <> foldMap (\expr -> [ line "Relevant expression: "
521524 , indent $ prettyPrintValue valueDepth expr
522525 ]) binding
523− renderSimpleErrorMessage (TypesDoNotUnify t1 t2)
524− = paras [ line "Could not match type"
525− , indent $ typeAsBox t1
526− , line "with type"
527− , indent $ typeAsBox t2
528− ]
526+ renderSimpleErrorMessage (TypesDoNotUnify u1 u2)
527+ = let (sorted1, sorted2) = sortRows u1 u2
528+
529+ sortRows :: Type -> Type -> (Type, Type)
530+ sortRows r1@RCons{} r2@RCons{} = sortRows' (rowToList r1) (rowToList r2)
531+ sortRows t1 t2 = (t1, t2)
532+
533+ -- Put the common labels last
534+ sortRows' :: ([(String, Type)], Type) -> ([(String, Type)], Type) -> (Type, Type)
535+ sortRows' (s1, r1) (s2, r2) =
536+ let common :: [(String, (Type, Type))]
537+ common = sortBy (comparing fst) $ [ (name, (t1, t2)) | (name, t1) <- s1, (name', t2) <- s2, name == name' ]
538+
539+ sd1, sd2 :: [(String, Type)]
540+ sd1 = [ (name, t1) | (name, t1) <- s1, name `notElem` map fst s2 ]
541+ sd2 = [ (name, t2) | (name, t2) <- s2, name `notElem` map fst s1 ]
542+ in ( rowFromList (sortBy (comparing fst) sd1 ++ map (fst &&& fst . snd) common, r1)
543+ , rowFromList (sortBy (comparing fst) sd2 ++ map (fst &&& snd . snd) common, r2)
544+ )
545+ in paras [ line "Could not match type"
546+ , indent $ typeAsBox sorted1
547+ , line "with type"
548+ , indent $ typeAsBox sorted2
549+ ]
550+
529551 renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
530552 paras [ line "Could not match kind"
531553 , indent $ line $ prettyPrintKind k1
@@ -692,6 +714,10 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
692714 paras [ line $ "The import of type " ++ runProperName name ++ " includes the following unused data constructors:"
693715 , indent $ paras $ map (line .runProperName) names ]
694716
717+ renderSimpleErrorMessage (DeprecatedQualifiedSyntax name qualName) =
718+ paras [ line $ "The import of type " ++ runModuleName name ++ " as " ++ runModuleName qualName ++ " uses the deprecated 'import qualified' syntax."
719+ , line $ "This syntax form will be removed in PureScript 0.9." ]
720+
695721 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
696722 renderHint (ErrorUnifyingTypes t1 t2) detail =
697723 paras [ detail
src/Language/PureScript/Externs.hs+1−1
@@ -173,7 +173,7 @@ moduleToExternsFile (Module _ _ mn ds (Just exps)) env = ExternsFile{..}
173173 fixityDecl _ = Nothing
174174
175175 importDecl :: Declaration -> Maybe ExternsImport
176− importDecl (ImportDeclaration m mt qmn) = Just (ExternsImport m mt qmn)
176+ importDecl (ImportDeclaration m mt qmn _) = Just (ExternsImport m mt qmn)
177177 importDecl (PositionedDeclaration _ _ d) = importDecl d
178178 importDecl _ = Nothing
179179
src/Language/PureScript/Make.hs+14−12
@@ -63,6 +63,7 @@ import Data.Traversable (for)
6363import Data.Version (showVersion)
6464import Data.Aeson (encode, decode)
6565import qualified Data.ByteString.Lazy as B
66+import qualified Data.ByteString.UTF8 as BU8
6667import qualified Data.Set as S
6768import qualified Data.Map as M
6869
@@ -70,6 +71,7 @@ import System.Directory
7071 (doesFileExist, getModificationTime, createDirectoryIfMissing)
7172import System.FilePath ((</>), takeDirectory)
7273import System.IO.Error (tryIOError)
74+import System.IO.UTF8 (readUTF8File, writeUTF8File)
7375
7476import Language.PureScript.Crash
7577import Language.PureScript.AST
@@ -123,7 +125,7 @@ data MakeActions m = MakeActions {
123125 -- |
124126 -- Read the externs file for a module as a string and also return the actual
125127 -- path for the file.
126− , readExterns :: ModuleName -> m (FilePath, B.ByteString)
128+ , readExterns :: ModuleName -> m (FilePath, Externs)
127129 -- |
128130 -- Run the code generator for the module and write any required output files.
129131 --
@@ -137,7 +139,7 @@ data MakeActions m = MakeActions {
137139-- |
138140-- Generated code for an externs file.
139141--
140−type Externs = B.ByteString
142+type Externs = String
141143
142144-- |
143145-- Determines when to rebuild a module
@@ -231,7 +233,7 @@ make MakeActions{..} ms = do
231233 corefn = CF.moduleToCoreFn env' mod'
232234 [renamed] = renameInModules [corefn]
233235 exts = moduleToExternsFile mod' env'
234− evalSupplyT nextVar $ codegen renamed env' $ encode exts
236+ evalSupplyT nextVar . codegen renamed env' . BU8.toString . B.toStrict . encode $ exts
235237 return exts
236238 markComplete (Just (warnings, exts)) Nothing
237239
@@ -258,9 +260,9 @@ make MakeActions{..} ms = do
258260 shouldExist (Just t) = t
259261 shouldExist _ = internalError "make: dependency should already have been built."
260262
261− decodeExterns :: B.ByteString -> Maybe ExternsFile
263+ decodeExterns :: Externs -> Maybe ExternsFile
262264 decodeExterns bs = do
263− externs <- decode bs
265+ externs <- decode (fromString bs)
264266 guard $ efVersion externs == showVersion Paths.version
265267 return externs
266268
@@ -270,9 +272,9 @@ make MakeActions{..} ms = do
270272addDefaultImport :: ModuleName -> Module -> Module
271273addDefaultImport toImport m@(Module ss coms mn decls exps) =
272274 if isExistingImport `any` decls || mn == toImport then m
273− else Module ss coms mn (ImportDeclaration toImport Implicit Nothing : decls) exps
275+ else Module ss coms mn (ImportDeclaration toImport Implicit Nothing False : decls) exps
274276 where
275− isExistingImport (ImportDeclaration mn' _ _) | mn' == toImport = True
277+ isExistingImport (ImportDeclaration mn' _ _ _) | mn' == toImport = True
276278 isExistingImport (PositionedDeclaration _ _ d) = isExistingImport d
277279 isExistingImport _ = False
278280
@@ -335,7 +337,7 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
335337 externsFile = outputDir </> filePath </> "externs.json"
336338 min <$> getTimestamp jsFile <*> getTimestamp externsFile
337339
338− readExterns :: ModuleName -> Make (FilePath, B.ByteString)
340+ readExterns :: ModuleName -> Make (FilePath, Externs)
339341 readExterns mn = do
340342 let path = outputDir </> runModuleName mn </> "externs.json"
341343 (path, ) <$> readTextFile path
@@ -371,13 +373,13 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
371373 exists <- doesFileExist path
372374 traverse (const $ getModificationTime path) $ guard exists
373375
374− readTextFile :: FilePath -> Make B.ByteString
375− readTextFile path = makeIO (const (ErrorMessage [] $ CannotReadFile path)) $ B.readFile path
376+ readTextFile :: FilePath -> Make String
377+ readTextFile path = makeIO (const (ErrorMessage [] $ CannotReadFile path)) $ readUTF8File path
376378
377− writeTextFile :: FilePath -> B.ByteString -> Make ()
379+ writeTextFile :: FilePath -> String -> Make ()
378380 writeTextFile path text = makeIO (const (ErrorMessage [] $ CannotWriteFile path)) $ do
379381 mkdirp path
380− B.writeFile path text
382+ writeUTF8File path text
381383 where
382384 mkdirp :: FilePath -> IO ()
383385 mkdirp = createDirectoryIfMissing True . takeDirectory
src/Language/PureScript/ModuleDependencies.hs+1−1
@@ -57,7 +57,7 @@ usedModules :: Declaration -> [ModuleName]
5757usedModules = let (f, _, _, _, _) = everythingOnValues (++) forDecls forValues (const []) (const []) (const []) in nub . f
5858 where
5959 forDecls :: Declaration -> [ModuleName]
60− forDecls (ImportDeclaration mn _ _) = [mn]
60+ forDecls (ImportDeclaration mn _ _ _) = [mn]
6161 forDecls _ = []
6262
6363 forValues :: Expr -> [ModuleName]
src/Language/PureScript/Parser/Declarations.hs+7−14
@@ -141,10 +141,10 @@ parseFixityDeclaration = do
141141
142142parseImportDeclaration :: TokenParser Declaration
143143parseImportDeclaration = do
144− (mn, declType, asQ) <- parseImportDeclaration'
145− return $ ImportDeclaration mn declType asQ
144+ (mn, declType, asQ, isOldSyntax) <- parseImportDeclaration'
145+ return $ ImportDeclaration mn declType asQ isOldSyntax
146146
147−parseImportDeclaration' :: TokenParser (ModuleName, ImportDeclarationType, Maybe ModuleName)
147+parseImportDeclaration' :: TokenParser (ModuleName, ImportDeclarationType, Maybe ModuleName, Bool)
148148parseImportDeclaration' = do
149149 reserved "import"
150150 indented
@@ -152,16 +152,9 @@ parseImportDeclaration' = do
152152 where
153153 stdImport = do
154154 moduleName' <- moduleName
155− suffixHiding moduleName' <|> suffixQualifyingList moduleName'
156− where
157− suffixHiding mn = do
158− reserved "hiding"
159− declType <- qualifyingList Hiding
160− return (mn, declType, Nothing)
161− suffixQualifyingList mn = do
162− declType <- qualifyingList Explicit
163− qName <- P.optionMaybe qualifiedName
164− return (mn, declType, qName)
155+ declType <- reserved "hiding" *> qualifyingList Hiding <|> qualifyingList Explicit
156+ qName <- P.optionMaybe qualifiedName
157+ return (moduleName', declType, qName, False)
165158 qualifiedName = reserved "as" *> moduleName
166159 qualImport = do
167160 reserved "qualified"
@@ -169,7 +162,7 @@ parseImportDeclaration' = do
169162 moduleName' <- moduleName
170163 declType <- qualifyingList Explicit
171164 qName <- qualifiedName
172− return (moduleName', declType, Just qName)
165+ return (moduleName', declType, Just qName, True)
173166 qualifyingList expectedType = do
174167 idents <- P.optionMaybe $ indented *> parens (commaSep parseDeclarationRef)
175168 return $ fromMaybe Implicit (expectedType <$> idents)
src/Language/PureScript/Pretty/Types.hs+1−1
@@ -79,7 +79,7 @@ prettyPrintRowWith open close = uncurry listToBox . toList []
7979
8080 toList :: [(String, Type)] -> Type -> ([(String, Type)], Type)
8181 toList tys (RCons name ty row) = toList ((name, ty):tys) row
82− toList tys r = (tys, r)
82+ toList tys r = (reverse tys, r)
8383
8484prettyPrintRow :: Type -> String
8585prettyPrintRow = render . prettyPrintRowWith '(' ')'
src/Language/PureScript/Sugar/Names.hs+1−1
@@ -142,7 +142,7 @@ elaborateImports imps (Module ss coms mn decls exps) = Module ss coms mn decls'
142142 fqValues (Var (Qualified (Just mn') _)) | mn' `notElem` importedModules imps = [mn']
143143 fqValues _ = []
144144 mkImport :: ModuleName -> Declaration
145− mkImport mn' = ImportDeclaration mn' (Explicit []) Nothing
145+ mkImport mn' = ImportDeclaration mn' (Explicit []) Nothing False
146146
147147-- |
148148-- Replaces all local names with qualified names within a module and checks that all existing
src/Language/PureScript/Sugar/Names/Exports.hs+1−1
@@ -141,7 +141,7 @@ resolveExports env mn imps exps refs =
141141 go (Qualified (Just mn'') name) = fromMaybe (internalError "Missing value in resolveTypeExports") $ do
142142 exps' <- envModuleExports <$> mn'' `M.lookup` env
143143 ((_, dctors'), mnOrig) <- find (\((name', _), _) -> name == name') (exportedTypes exps')
144− let relevantDctors = mapMaybe (\(Qualified mn''' dctor) -> if mn''' == Just mnOrig then Just dctor else Nothing) dctors
144+ let relevantDctors = mapMaybe (\(Qualified mn''' dctor) -> if mn''' == Just mn'' then Just dctor else Nothing) dctors
145145 return ((name, intersect relevantDctors dctors'), mnOrig)
146146 go (Qualified Nothing _) = internalError "Unqualified value in resolveTypeExports"
147147
src/Language/PureScript/Sugar/Names/Imports.hs+3−2
@@ -25,7 +25,7 @@ import Prelude ()
2525import Prelude.Compat
2626
2727import Data.List (find)
28−import Data.Maybe (fromMaybe, isNothing)
28+import Data.Maybe (fromMaybe, isNothing, fromJust)
2929import Data.Foldable (traverse_)
3030
3131import Control.Arrow (first)
@@ -48,7 +48,8 @@ import Language.PureScript.Sugar.Names.Env
4848findImports :: forall m. (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) => [Declaration] -> m (M.Map ModuleName [(Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)])
4949findImports = foldM (go Nothing) M.empty
5050 where
51− go pos result (ImportDeclaration mn typ qual) = do
51+ go pos result (ImportDeclaration mn typ qual isOldSyntax) = do
52+ when isOldSyntax . tell . errorMessage $ DeprecatedQualifiedSyntax mn (fromJust qual)
5253 checkImportRefType typ
5354 let imp = (pos, typ, qual)
5455 return $ M.insert mn (maybe [imp] (imp :) (mn `M.lookup` result)) result
src/Language/PureScript/TypeChecker/Types.hs+1−2
@@ -213,8 +213,7 @@ instantiatePolyTypeWithUnknowns val (ForAll ident ty _) = do
213213 instantiatePolyTypeWithUnknowns val ty'
214214instantiatePolyTypeWithUnknowns val (ConstrainedType constraints ty) = do
215215 dicts <- getTypeClassDictionaries
216− (_, ty') <- instantiatePolyTypeWithUnknowns (internalError "Types under a constraint cannot themselves be constrained") ty
217− return (foldl App val (map (flip TypeClassDictionary dicts) constraints), ty')
216+ instantiatePolyTypeWithUnknowns (foldl App val (map (flip TypeClassDictionary dicts) constraints)) ty
218217instantiatePolyTypeWithUnknowns val ty = return (val, ty)
219218
220219-- | Infer a type for a value, rethrowing any error to provide a more useful error message
src/Language/PureScript/TypeChecker/Unify.hs+1−1
@@ -163,7 +163,7 @@ unifyRows r1 r2 =
163163 unifyRows' [] REmpty [] REmpty = return ()
164164 unifyRows' [] (TypeVar v1) [] (TypeVar v2) | v1 == v2 = return ()
165165 unifyRows' [] (Skolem _ s1 _) [] (Skolem _ s2 _) | s1 == s2 = return ()
166− unifyRows' sd3 r3 sd4 r4 = throwError . errorMessage $ TypesDoNotUnify (rowFromList (sd3, r3)) (rowFromList (sd4, r4))
166+ unifyRows' _ _ _ _ = throwError . errorMessage $ TypesDoNotUnify r1 r2
167167
168168-- |
169169-- Check that two types unify
src/System/IO/UTF8.hs+20−4
@@ -1,9 +1,25 @@
11module System.IO.UTF8
2+
23where
3−import System.IO (hGetContents, hSetEncoding, openFile, utf8, IOMode (..))
4+
5+import System.IO ( IOMode(..)
6+ , hGetContents
7+ , hSetEncoding
8+ , hClose
9+ , hPutStr
10+ , openFile
11+ , utf8
12+ )
413
514readUTF8File :: FilePath -> IO String
615readUTF8File inFile = do
7− h <- openFile inFile ReadMode
8− hSetEncoding h utf8
9− hGetContents h
16+ h <- openFile inFile ReadMode
17+ hSetEncoding h utf8
18+ hGetContents h
19+
20+writeUTF8File :: FilePath -> String -> IO ()
21+writeUTF8File inFile text = do
22+ h <- openFile inFile WriteMode
23+ hSetEncoding h utf8
24+ hPutStr h text
25+ hClose h