git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'master' into pure11
eb5d4e4Andy Arvanitis
examples/passing/1991.pursnew file+20
@@ -0,0 +1,20 @@
1+module Main where
2+
3+import Prelude
4+
5+singleton :: forall a. a -> Array a
6+singleton x = [x]
7+
8+empty :: forall a. Array a
9+empty = []
10+
11+foldMap :: forall a m. (Semigroup m) => (a -> m) -> Array a -> m
12+foldMap f [a, b, c, d, e] = f a <> f b <> f c <> f d <> f e
13+
14+regression :: Array Int
15+regression =
16+ let as = [1,2,3,4,5]
17+ as' = foldMap (\x -> if 1 < x && x < 4 then singleton x else empty) as
18+ in as'
19+
20+main = Control.Monad.Eff.Console.log "Done"
psc-bundle/Main.hs+5−16
@@ -1,25 +1,12 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : psc-bundle
4−-- Copyright : (c) Phil Freeman 2015
5−-- License : MIT
6−--
7−-- Maintainer : Phil Freeman <paf31@cantab.net>
8−-- Stability : experimental
9−-- Portability :
10−--
11−-- | Bundles compiled PureScript modules for the browser.
12−--
13−-----------------------------------------------------------------------------
14−
15{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
16{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
17{-# LANGUAGE TupleSections #-}
3{-# LANGUAGE TupleSections #-}
18{-# LANGUAGE RecordWildCards #-}
4{-# LANGUAGE RecordWildCards #-}
19
5
6+-- | Bundles compiled PureScript modules for the browser.
20module Main (main) where
7module Main (main) where
21
8
22−import Data.Maybe
9+import Data.Maybe
23import Data.Traversable (for)
10import Data.Traversable (for)
24import Data.Version (showVersion)
11import Data.Version (showVersion)
25
12
@@ -32,7 +19,7 @@ import Control.Monad.IO.Class
32import System.FilePath (takeFileName, takeDirectory)
19import System.FilePath (takeFileName, takeDirectory)
33import System.FilePath.Glob (glob)
20import System.FilePath.Glob (glob)
34import System.Exit (exitFailure)
21import System.Exit (exitFailure)
35−import System.IO (stderr, hPutStrLn)
22+import System.IO (stderr, stdout, hPutStrLn, hSetEncoding, utf8)
36import System.Directory (createDirectoryIfMissing)
23import System.Directory (createDirectoryIfMissing)
37
24
38import Language.PureScript.Bundle
25import Language.PureScript.Bundle
@@ -125,6 +112,8 @@ options = Options <$> some inputFile
125-- | Make it go.
112-- | Make it go.
126main :: IO ()
113main :: IO ()
127main = do
114main = do
115+ hSetEncoding stdout utf8
116+ hSetEncoding stderr utf8
128 opts <- execParser (info (version <*> helper <*> options) infoModList)
117 opts <- execParser (info (version <*> helper <*> options) infoModList)
129 when (isJust (optionsRequirePath opts)) $ hPutStrLn stderr "The require-path option is deprecated and will be removed in PureScript 0.9."
118 when (isJust (optionsRequirePath opts)) $ hPutStrLn stderr "The require-path option is deprecated and will be removed in PureScript 0.9."
130 output <- runExceptT (app opts)
119 output <- runExceptT (app opts)
psc-docs/Main.hs+5−15
@@ -1,17 +1,4 @@
1{-# LANGUAGE TupleSections #-}
1{-# LANGUAGE TupleSections #-}
2−----------------------------------------------------------------------------
3−--
4−-- Module : Main
5−-- Copyright : (c) Phil Freeman 2013
6−-- License : MIT
7−--
8−-- Maintainer : Phil Freeman <paf31@cantab.net>
9−-- Stability : experimental
10−-- Portability :
11−--
12−-- |
13−--
14−-----------------------------------------------------------------------------
15
2
16module Main where
3module Main where
17
4
@@ -32,7 +19,7 @@ import qualified Text.PrettyPrint.ANSI.Leijen as PP
32import qualified Language.PureScript as P
19import qualified Language.PureScript as P
33import qualified Paths_purescript as Paths
20import qualified Paths_purescript as Paths
34import System.Exit (exitFailure)
21import System.Exit (exitFailure)
35−import System.IO (hPutStrLn, hPrint, stderr)
22+import System.IO (hPutStrLn, hPrint, hSetEncoding, stderr, stdout, utf8)
36import System.Directory (createDirectoryIfMissing)
23import System.Directory (createDirectoryIfMissing)
37import System.FilePath (takeDirectory)
24import System.FilePath (takeDirectory)
38import System.FilePath.Glob (glob)
25import System.FilePath.Glob (glob)
@@ -228,7 +215,10 @@ buildOptions (fmt, input, mapping) =
228 exitFailure
215 exitFailure
229
216
230main :: IO ()
217main :: IO ()
218+main = do
219+ hSetEncoding stdout utf8
220+ hSetEncoding stderr utf8
231−main = execParser opts >>= buildOptions >>= docgen
221+ execParser opts >>= buildOptions >>= docgen
232 where
222 where
233 opts = info (version <*> helper <*> pscDocsOptions) infoModList
223 opts = info (version <*> helper <*> pscDocsOptions) infoModList
234 infoModList = fullDesc <> headerInfo <> footerInfo
224 infoModList = fullDesc <> headerInfo <> footerInfo
psc-publish/Main.hs+6−1
@@ -7,6 +7,8 @@ import qualified Data.ByteString.Lazy.Char8 as BL
7
7
8import Options.Applicative hiding (str)
8import Options.Applicative hiding (str)
9
9
10+import System.IO (hSetEncoding, stderr, stdout, utf8)
11+
10import qualified Paths_purescript as Paths
12import qualified Paths_purescript as Paths
11import Language.PureScript.Publish
13import Language.PureScript.Publish
12import Language.PureScript.Publish.ErrorsWarnings
14import Language.PureScript.Publish.ErrorsWarnings
@@ -24,7 +26,10 @@ dryRunOptions = defaultPublishOptions
24 where dummyVersion = ("0.0.0", Version [0,0,0] [])
26 where dummyVersion = ("0.0.0", Version [0,0,0] [])
25
27
26main :: IO ()
28main :: IO ()
29+main = do
30+ hSetEncoding stdout utf8
31+ hSetEncoding stderr utf8
27−main = execParser opts >>= publish
32+ execParser opts >>= publish
28 where
33 where
29 opts = info (version <*> helper <*> dryRun) infoModList
34 opts = info (version <*> helper <*> dryRun) infoModList
30 infoModList = fullDesc <> headerInfo <> footerInfo
35 infoModList = fullDesc <> headerInfo <> footerInfo
psc/Main.hs+5−16
@@ -1,17 +1,3 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : Main
4−-- Copyright : (c) 2013-15 Phil Freeman, (c) 2014-15 Gary Burgess
5−-- License : MIT (http://opensource.org/licenses/MIT)
6−--
7−-- Maintainer : Phil Freeman <paf31@cantab.net>
8−-- Stability : experimental
9−-- Portability :
10−--
11−-- |
12−--
13−-----------------------------------------------------------------------------
14−
15{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
16{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
17{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE RecordWildCards #-}
@@ -34,7 +20,7 @@ import qualified Data.ByteString.UTF8 as BU8
34import Options.Applicative as Opts
20import Options.Applicative as Opts
35
21
36import System.Exit (exitSuccess, exitFailure)
22import System.Exit (exitSuccess, exitFailure)
37−import System.IO (hPutStrLn, stderr)
23+import System.IO (hSetEncoding, hPutStrLn, stdout, stderr, utf8)
38import System.IO.UTF8
24import System.IO.UTF8
39import System.FilePath.Glob (glob)
25import System.FilePath.Glob (glob)
40
26
@@ -202,7 +188,10 @@ pscMakeOptions = PSCMakeOptions <$> many inputFile
202 <*> jsonErrors
188 <*> jsonErrors
203
189
204main :: IO ()
190main :: IO ()
191+main = do
192+ hSetEncoding stdout utf8
193+ hSetEncoding stderr utf8
205−main = execParser opts >>= compile
194+ execParser opts >>= compile
206 where
195 where
207 opts = info (version <*> helper <*> pscMakeOptions) infoModList
196 opts = info (version <*> helper <*> pscMakeOptions) infoModList
208 infoModList = fullDesc <> headerInfo <> footerInfo
197 infoModList = fullDesc <> headerInfo <> footerInfo
src/Language/PureScript/TypeChecker/Types.hs+5−3
@@ -179,7 +179,7 @@ overTypes f = let (_, f', _) = everywhereOnValues id g id in f'
179 g (TypedValue checkTy val t) = TypedValue checkTy val (f t)
179 g (TypedValue checkTy val t) = TypedValue checkTy val (f t)
180 g (TypeClassDictionary (nm, tys) sco) = TypeClassDictionary (nm, map f tys) sco
180 g (TypeClassDictionary (nm, tys) sco) = TypeClassDictionary (nm, map f tys) sco
181 g other = other
181 g other = other
182−
182+
183-- | Check the kind of a type, failing if it is not of kind *.
183-- | Check the kind of a type, failing if it is not of kind *.
184checkTypeKind ::
184checkTypeKind ::
185 (MonadState CheckState m, MonadError MultipleErrors m) =>
185 (MonadState CheckState m, MonadError MultipleErrors m) =>
@@ -283,8 +283,10 @@ infer' (IfThenElse cond th el) = do
283 cond' <- check cond tyBoolean
283 cond' <- check cond tyBoolean
284 th'@(TypedValue _ _ thTy) <- infer th
284 th'@(TypedValue _ _ thTy) <- infer th
285 el'@(TypedValue _ _ elTy) <- infer el
285 el'@(TypedValue _ _ elTy) <- infer el
286+ (th'', thTy') <- instantiatePolyTypeWithUnknowns th' thTy
287+ (el'', elTy') <- instantiatePolyTypeWithUnknowns el' elTy
286− unifyTypes thTy elTy
288+ unifyTypes thTy' elTy'
287− return $ TypedValue True (IfThenElse cond' th' el') thTy
289+ return $ TypedValue True (IfThenElse cond' th'' el'') thTy'
288infer' (Let ds val) = do
290infer' (Let ds val) = do
289 (ds', val'@(TypedValue _ _ valTy)) <- inferLetBinding [] ds val infer
291 (ds', val'@(TypedValue _ _ valTy)) <- inferLetBinding [] ds val infer
290 return $ TypedValue True (Let ds' val') valTy
292 return $ TypedValue True (Let ds' val') valTy