git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge master
5674d64Phil Freeman
.travis.yml+1−14
@@ -2,26 +2,13 @@ language: c
2sudo: false
2sudo: false
3matrix:
3matrix:
4 include:
4 include:
5− - env: GHCVER=7.8.4 CABALVER=1.22 COVERAGE=true
6− compiler: ": #GHC 7.8.4 - tests"
7− # ^ HACK before https://github.com/travis-ci/travis-ci/issues/4393 is resolved
8− addons: {apt: {packages: [cabal-install-1.22,ghc-7.8.4,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
9− - env: GHCVER=7.6.3 CABALVER=1.22
10− compiler: ": #GHC 7.6.3"
11− addons: {apt: {packages: [cabal-install-1.22,ghc-7.6.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
12− - env: GHCVER=7.10.1 CABALVER=1.22 DEPLOY=yes
13− compiler: ": #GHC 7.10.1"
14− addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
15− - env: GHCVER=7.10.2 CABALVER=1.22 STACKAGE=lts-3.22 RUNSDISTTESTS=YES
16− compiler: ": #GHC 7.10.2 lts-3.22"
17− addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
18 - env: GHCVER=7.10.3 CABALVER=1.22 STACKAGE=lts-5.4 RUNSDISTTESTS=YES
5 - env: GHCVER=7.10.3 CABALVER=1.22 STACKAGE=lts-5.4 RUNSDISTTESTS=YES
19 compiler: ": #GHC 7.10.3 lts-5.4"
6 compiler: ": #GHC 7.10.3 lts-5.4"
20 addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
7 addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
21 - env: GHCVER=7.10.3 CABALVER=1.22 STACKAGE=nightly-2016-02-25
8 - env: GHCVER=7.10.3 CABALVER=1.22 STACKAGE=nightly-2016-02-25
22 compiler: ": #GHC 7.10.3 nightly-2016-02-25"
9 compiler: ": #GHC 7.10.3 nightly-2016-02-25"
23 addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
10 addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
24− - env: GHCVER=7.10.3 CABALVER=1.22
11+ - env: GHCVER=7.10.3 CABALVER=1.22 DEPLOY=yes
25 compiler: ": #GHC 7.10.3"
12 compiler: ": #GHC 7.10.3"
26 addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
13 addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
27before_install:
14before_install:
INSTALL.md+4−8
@@ -6,8 +6,8 @@ alternatively Stack Overflow.
6
6
7## Using prebuilt binaries
7## Using prebuilt binaries
8
8
9−The prebuilt binaries are compiled with GHC 7.8.4, and therefore they should
9+The prebuilt binaries are compiled with GHC 7.10.3, and therefore they should
10−run on any operating system supported by GHC 7.8.4, such as:
10+run on any operating system supported by GHC 7.10.3, such as:
11
11
12* Windows 2000 or later,
12* Windows 2000 or later,
13* OS X 10.7 or later,
13* OS X 10.7 or later,
@@ -23,11 +23,11 @@ requirements.
23
23
24## Compiling from source
24## Compiling from source
25
25
26−GHC 7.6.1 or newer is required to compile from source. The easiest way is to
26+GHC 7.10.1 or newer is required to compile from source. The easiest way is to
27use stack:
27use stack:
28
28
29```
29```
30−$ stack install --resolver lts purescript
30+$ stack install --resolver=nightly purescript
31```
31```
32
32
33This will then copy the compiler and utilities into `~/.local/bin`.
33This will then copy the compiler and utilities into `~/.local/bin`.
@@ -39,10 +39,6 @@ If you don't have stack installed yet there are install instructions
39If you don't have ghc installed yet, stack will prompt you to run `stack setup`
39If you don't have ghc installed yet, stack will prompt you to run `stack setup`
40which will install ghc for you.
40which will install ghc for you.
41
41
42−The PureScript compiler has been known to run on OS X 10.6 when built with GHC
43−7.6.
44−
45−
46## The "curses" library
42## The "curses" library
47
43
48`psci` depends on the `curses` library (via the Haskell package `terminfo`). If
44`psci` depends on the `curses` library (via the Haskell package `terminfo`). If
psc-bundle/Main.hs+2−2
@@ -51,7 +51,7 @@ data Options = Options
51 } deriving Show
51 } deriving Show
52
52
53-- | Given a filename, assuming it is in the correct place on disk, infer a ModuleIdentifier.
53-- | Given a filename, assuming it is in the correct place on disk, infer a ModuleIdentifier.
54−guessModuleIdentifier :: (Applicative m, MonadError ErrorMessage m) => FilePath -> m ModuleIdentifier
54+guessModuleIdentifier :: (MonadError ErrorMessage m) => FilePath -> m ModuleIdentifier
55guessModuleIdentifier filename = ModuleIdentifier (takeFileName (takeDirectory filename)) <$> guessModuleType (takeFileName filename)
55guessModuleIdentifier filename = ModuleIdentifier (takeFileName (takeDirectory filename)) <$> guessModuleType (takeFileName filename)
56 where
56 where
57 guessModuleType "index.js" = pure Regular
57 guessModuleType "index.js" = pure Regular
@@ -61,7 +61,7 @@ guessModuleIdentifier filename = ModuleIdentifier (takeFileName (takeDirectory f
61-- | The main application function.
61-- | The main application function.
62-- This function parses the input files, performs dead code elimination, filters empty modules
62-- This function parses the input files, performs dead code elimination, filters empty modules
63-- and generates and prints the final Javascript bundle.
63-- and generates and prints the final Javascript bundle.
64−app :: (Applicative m, MonadError ErrorMessage m, MonadIO m) => Options -> m String
64+app :: (MonadError ErrorMessage m, MonadIO m) => Options -> m String
65app Options{..} = do
65app Options{..} = do
66 inputFiles <- concat <$> mapM (liftIO . glob) optionsInputFiles
66 inputFiles <- concat <$> mapM (liftIO . glob) optionsInputFiles
67 when (null inputFiles) . liftIO $ do
67 when (null inputFiles) . liftIO $ do
psc-ide-server/Main.hs+1−1
@@ -124,7 +124,7 @@ startServer port env = withSocketsDo $ do
124 liftIO (hClose h)
124 liftIO (hClose h)
125
125
126
126
127−acceptCommand :: (Applicative m, MonadIO m, MonadLogger m, MonadError T.Text m)
127+acceptCommand :: (MonadIO m, MonadLogger m, MonadError T.Text m)
128 => Socket -> m (T.Text, Handle)
128 => Socket -> m (T.Text, Handle)
129acceptCommand sock = do
129acceptCommand sock = do
130 h <- acceptConnection
130 h <- acceptConnection
psc/Main.hs+1−1
@@ -107,7 +107,7 @@ globWarningOnMisses warn = concatMapM globWithWarning
107readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
107readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
108readInput InputOptions{..} = forM ioInputFiles $ \inFile -> (Right inFile, ) <$> readUTF8File inFile
108readInput InputOptions{..} = forM ioInputFiles $ \inFile -> (Right inFile, ) <$> readUTF8File inFile
109
109
110−parseInputs :: (Functor m, Applicative m, MonadError P.MultipleErrors m, MonadWriter P.MultipleErrors m)
110+parseInputs :: (MonadError P.MultipleErrors m, MonadWriter P.MultipleErrors m)
111 => [(Either P.RebuildPolicy FilePath, String)]
111 => [(Either P.RebuildPolicy FilePath, String)]
112 -> [(FilePath, P.ForeignJS)]
112 -> [(FilePath, P.ForeignJS)]
113 -> m ([(Either P.RebuildPolicy FilePath, P.Module)], M.Map P.ModuleName FilePath)
113 -> m ([(Either P.RebuildPolicy FilePath, P.Module)], M.Map P.ModuleName FilePath)
purescript.cabal+10−11
@@ -17,7 +17,7 @@ author: Phil Freeman <paf31@cantab.net>,
17 Harry Garrood <harry@garrood.me>,
17 Harry Garrood <harry@garrood.me>,
18 Christoph Hegemann <christoph.hegemann1337@gmail.com>
18 Christoph Hegemann <christoph.hegemann1337@gmail.com>
19
19
20−tested-with: GHC==7.8.4, GHC==7.10.3, GHC==8.0.1
20+tested-with: GHC==7.10.3
21
21
22extra-source-files: examples/passing/*.purs
22extra-source-files: examples/passing/*.purs
23 , examples/failing/*.purs
23 , examples/failing/*.purs
@@ -36,8 +36,7 @@ extra-source-files: examples/passing/*.purs
36 , tests/support/flattened/*.js
36 , tests/support/flattened/*.js
37 , tests/support/psci/*.purs
37 , tests/support/psci/*.purs
38 , stack.yaml
38 , stack.yaml
39− , stack-lts-2.yaml
39+ , stack-lts-5.yaml
40− , stack-lts-3.yaml
41 , stack-nightly.yaml
40 , stack-nightly.yaml
42 , README.md
41 , README.md
43 , INSTALL.md
42 , INSTALL.md
@@ -49,7 +48,7 @@ source-repository head
49 location: https://github.com/purescript/purescript.git
48 location: https://github.com/purescript/purescript.git
50
49
51library
50library
52− build-depends: base >=4.6 && <5,
51+ build-depends: base >=4.8 && <5,
53 base-compat >=0.6.0,
52 base-compat >=0.6.0,
54 lifted-base >= 0.2.3 && < 0.2.4,
53 lifted-base >= 0.2.3 && < 0.2.4,
55 monad-control >= 1.0.0.0 && < 1.1,
54 monad-control >= 1.0.0.0 && < 1.1,
@@ -229,7 +228,7 @@ library
229executable psc
228executable psc
230 build-depends: base >=4 && <5, base-compat >=0.6.0,
229 build-depends: base >=4 && <5, base-compat >=0.6.0,
231 containers -any, directory -any, filepath -any,
230 containers -any, directory -any, filepath -any,
232− mtl -any, optparse-applicative >= 0.10.0, parsec -any, purescript -any,
231+ mtl -any, optparse-applicative >= 0.12.1, parsec -any, purescript -any,
233 time -any, transformers -any, transformers-compat -any, Glob >= 0.7 && < 0.8,
232 time -any, transformers -any, transformers-compat -any, Glob >= 0.7 && < 0.8,
234 aeson >= 0.8 && < 0.12, bytestring -any, utf8-string >= 1 && < 2
233 aeson >= 0.8 && < 0.12, bytestring -any, utf8-string >= 1 && < 2
235 main-is: Main.hs
234 main-is: Main.hs
@@ -240,7 +239,7 @@ executable psc
240
239
241executable psci
240executable psci
242 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
241 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
243− mtl -any, optparse-applicative >= 0.10.0, parsec -any,
242+ mtl -any, optparse-applicative >= 0.12.1, parsec -any,
244 haskeline >= 0.7.0.0, purescript -any, transformers -any,
243 haskeline >= 0.7.0.0, purescript -any, transformers -any,
245 transformers-compat -any, process -any, time -any, Glob -any, base-compat >=0.6.0,
244 transformers-compat -any, process -any, time -any, Glob -any, base-compat >=0.6.0,
246 boxes >= 0.1.4 && < 0.2.0
245 boxes >= 0.1.4 && < 0.2.0
@@ -263,7 +262,7 @@ executable psci
263
262
264executable psc-docs
263executable psc-docs
265 build-depends: base >=4 && <5, purescript -any,
264 build-depends: base >=4 && <5, purescript -any,
266− optparse-applicative >= 0.10.0, process -any, mtl -any,
265+ optparse-applicative >= 0.12.1, process -any, mtl -any,
267 split -any, ansi-wl-pprint -any, directory -any,
266 split -any, ansi-wl-pprint -any, directory -any,
268 filepath -any, Glob -any, transformers -any,
267 filepath -any, Glob -any, transformers -any,
269 transformers-compat -any
268 transformers-compat -any
@@ -285,7 +284,7 @@ executable psc-publish
285 ghc-options: -Wall -O2
284 ghc-options: -Wall -O2
286
285
287executable psc-hierarchy
286executable psc-hierarchy
288− build-depends: base >=4 && <5, purescript -any, optparse-applicative >= 0.10.0,
287+ build-depends: base >=4 && <5, purescript -any, optparse-applicative >= 0.12.1,
289 process -any, mtl -any, parsec -any, filepath -any, directory -any,
288 process -any, mtl -any, parsec -any, filepath -any, directory -any,
290 Glob -any
289 Glob -any
291 main-is: Main.hs
290 main-is: Main.hs
@@ -306,7 +305,7 @@ executable psc-bundle
306 mtl -any,
305 mtl -any,
307 transformers -any,
306 transformers -any,
308 transformers-compat -any,
307 transformers-compat -any,
309− optparse-applicative >= 0.10.0,
308+ optparse-applicative >= 0.12.1,
310 Glob -any
309 Glob -any
311 ghc-options: -Wall -O2
310 ghc-options: -Wall -O2
312 hs-source-dirs: psc-bundle
311 hs-source-dirs: psc-bundle
@@ -324,7 +323,7 @@ executable psc-ide-server
324 , transformers -any
323 , transformers -any
325 , transformers-compat -any
324 , transformers-compat -any
326 , network -any
325 , network -any
327− , optparse-applicative >= 0.10.0
326+ , optparse-applicative >= 0.12.1
328 , stm -any
327 , stm -any
329 , text -any
328 , text -any
330 , base-compat >=0.6.0
329 , base-compat >=0.6.0
@@ -338,7 +337,7 @@ executable psc-ide-client
338 build-depends: base >=4 && <5
337 build-depends: base >=4 && <5
339 , mtl -any
338 , mtl -any
340 , text -any
339 , text -any
341− , optparse-applicative >= 0.10.0
340+ , optparse-applicative >= 0.12.1
342 , network -any
341 , network -any
343 , base-compat >=0.6.0
342 , base-compat >=0.6.0
344 ghc-options: -Wall -O2
343 ghc-options: -Wall -O2
src/Control/Monad/Supply.hs+1−1
@@ -27,7 +27,7 @@ import Control.Monad.Error.Class (MonadError(..))
27import Control.Monad.Reader
27import Control.Monad.Reader
28import Control.Monad.Writer
28import Control.Monad.Writer
29
29
30−newtype SupplyT m a = SupplyT { unSupplyT :: StateT Integer m a }
30+newtype SupplyT m a = SupplyT { unSupplyT :: StateT Integer m a }
31 deriving (Functor, Applicative, Monad, MonadTrans, MonadError e, MonadWriter w, MonadReader r)
31 deriving (Functor, Applicative, Monad, MonadTrans, MonadError e, MonadWriter w, MonadReader r)
32
32
33runSupplyT :: Integer -> SupplyT m a -> m (a, Integer)
33runSupplyT :: Integer -> SupplyT m a -> m (a, Integer)
src/Language/PureScript/AST/Traversals.hs+3−3
@@ -91,7 +91,7 @@ everywhereOnValues f g h = (f', g', h')
91
91
92everywhereOnValuesTopDownM
92everywhereOnValuesTopDownM
93 :: forall m
93 :: forall m
94− . (Functor m, Applicative m, Monad m)
94+ . (Monad m)
95 => (Declaration -> m Declaration)
95 => (Declaration -> m Declaration)
96 -> (Expr -> m Expr)
96 -> (Expr -> m Expr)
97 -> (Binder -> m Binder)
97 -> (Binder -> m Binder)
@@ -160,7 +160,7 @@ everywhereOnValuesTopDownM f g h = (f' <=< f, g' <=< g, h' <=< h)
160
160
161everywhereOnValuesM
161everywhereOnValuesM
162 :: forall m
162 :: forall m
163− . (Functor m, Applicative m, Monad m)
163+ . (Monad m)
164 => (Declaration -> m Declaration)
164 => (Declaration -> m Declaration)
165 -> (Expr -> m Expr)
165 -> (Expr -> m Expr)
166 -> (Binder -> m Binder)
166 -> (Binder -> m Binder)
@@ -389,7 +389,7 @@ everythingWithContextOnValues s0 r0 (<>) f g h i j = (f'' s0, g'' s0, h'' s0, i'
389
389
390everywhereWithContextOnValuesM
390everywhereWithContextOnValuesM
391 :: forall m s
391 :: forall m s
392− . (Functor m, Applicative m, Monad m)
392+ . (Monad m)
393 => s
393 => s
394 -> (s -> Declaration -> m (s, Declaration))
394 -> (s -> Declaration -> m (s, Declaration))
395 -> (s -> Expr -> m (s, Expr))
395 -> (s -> Expr -> m (s, Expr))
src/Language/PureScript/Bundle.hs+2−2
@@ -209,7 +209,7 @@ withDeps (Module modulePath es) = Module modulePath (map expandDeps es)
209--
209--
210-- Each type of module element is matched using pattern guards, and everything else is bundled into the
210-- Each type of module element is matched using pattern guards, and everything else is bundled into the
211-- Other constructor.
211-- Other constructor.
212−toModule :: forall m. (Applicative m, MonadError ErrorMessage m) => Maybe FilePath -> S.Set String -> ModuleIdentifier -> JSNode -> m Module
212+toModule :: forall m. (MonadError ErrorMessage m) => Maybe FilePath -> S.Set String -> ModuleIdentifier -> JSNode -> m Module
213toModule requirePath mids mid top
213toModule requirePath mids mid top
214 | JSSourceElementsTop ns <- node top = Module mid <$> traverse toModuleElement ns
214 | JSSourceElementsTop ns <- node top = Module mid <$> traverse toModuleElement ns
215 | otherwise = err InvalidTopLevel
215 | otherwise = err InvalidTopLevel
@@ -533,7 +533,7 @@ codeGen optionsMainModule optionsNamespace ms = renderToString (NN (JSSourceElem
533-- | The bundling function.
533-- | The bundling function.
534-- This function performs dead code elimination, filters empty modules
534-- This function performs dead code elimination, filters empty modules
535-- and generates and prints the final Javascript bundle.
535-- and generates and prints the final Javascript bundle.
536−bundle :: (Applicative m, MonadError ErrorMessage m)
536+bundle :: (MonadError ErrorMessage m)
537 => [(ModuleIdentifier, String)] -- ^ The input modules. Each module should be javascript rendered from 'Language.PureScript.Make' or @psc@.
537 => [(ModuleIdentifier, String)] -- ^ The input modules. Each module should be javascript rendered from 'Language.PureScript.Make' or @psc@.
538 -> [ModuleIdentifier] -- ^ Entry points. These module identifiers are used as the roots for dead-code elimination
538 -> [ModuleIdentifier] -- ^ Entry points. These module identifiers are used as the roots for dead-code elimination
539 -> Maybe String -- ^ An optional main module.
539 -> Maybe String -- ^ An optional main module.
src/Language/PureScript/CodeGen/JS.hs+1−1
@@ -47,7 +47,7 @@ import System.FilePath.Posix ((</>))
47--
47--
48moduleToJs
48moduleToJs
49 :: forall m
49 :: forall m
50− . (Applicative m, Monad m, MonadReader Options m, MonadSupply m, MonadError MultipleErrors m)
50+ . (Monad m, MonadReader Options m, MonadSupply m, MonadError MultipleErrors m)
51 => Module Ann
51 => Module Ann
52 -> Maybe JS
52 -> Maybe JS
53 -> m [JS]
53 -> m [JS]
src/Language/PureScript/CodeGen/JS/AST.hs+1−1
@@ -347,7 +347,7 @@ everywhereOnJS f = go
347everywhereOnJSTopDown :: (JS -> JS) -> JS -> JS
347everywhereOnJSTopDown :: (JS -> JS) -> JS -> JS
348everywhereOnJSTopDown f = runIdentity . everywhereOnJSTopDownM (Identity . f)
348everywhereOnJSTopDown f = runIdentity . everywhereOnJSTopDownM (Identity . f)
349
349
350−everywhereOnJSTopDownM :: (Applicative m, Monad m) => (JS -> m JS) -> JS -> m JS
350+everywhereOnJSTopDownM :: (Monad m) => (JS -> m JS) -> JS -> m JS
351everywhereOnJSTopDownM f = f >=> go
351everywhereOnJSTopDownM f = f >=> go
352 where
352 where
353 f' = f >=> go
353 f' = f >=> go
src/Language/PureScript/CodeGen/JS/Optimizer.hs+2−2
@@ -43,12 +43,12 @@ import Language.PureScript.CodeGen.JS.Optimizer.Blocks
43-- |
43-- |
44-- Apply a series of optimizer passes to simplified Javascript code
44-- Apply a series of optimizer passes to simplified Javascript code
45--
45--
46−optimize :: (Monad m, MonadReader Options m, Applicative m, MonadSupply m) => JS -> m JS
46+optimize :: (Monad m, MonadReader Options m, MonadSupply m) => JS -> m JS
47optimize js = do
47optimize js = do
48 noOpt <- asks optionsNoOptimizations
48 noOpt <- asks optionsNoOptimizations
49 if noOpt then return js else optimize' js
49 if noOpt then return js else optimize' js
50
50
51−optimize' :: (Monad m, MonadReader Options m, Applicative m, MonadSupply m) => JS -> m JS
51+optimize' :: (Monad m, MonadReader Options m, MonadSupply m) => JS -> m JS
52optimize' js = do
52optimize' js = do
53 opts <- ask
53 opts <- ask
54 js' <- untilFixedPoint (inlineFnComposition . tidyUp . applyAll
54 js' <- untilFixedPoint (inlineFnComposition . tidyUp . applyAll
src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+1−1
@@ -235,7 +235,7 @@ inlineCommonOperators = applyAll $
235
235
236-- (f <<< g $ x) = f (g x)
236-- (f <<< g $ x) = f (g x)
237-- (f <<< g) = \x -> f (g x)
237-- (f <<< g) = \x -> f (g x)
238−inlineFnComposition :: (Applicative m, MonadSupply m) => JS -> m JS
238+inlineFnComposition :: (MonadSupply m) => JS -> m JS
239inlineFnComposition = everywhereOnJSTopDownM convert
239inlineFnComposition = everywhereOnJSTopDownM convert
240 where
240 where
241 convert :: (MonadSupply m) => JS -> m JS
241 convert :: (MonadSupply m) => JS -> m JS
src/Language/PureScript/Docs/AsMarkdown.hs+1−2
@@ -29,8 +29,7 @@ import qualified Language.PureScript.Docs.Render as Render
29-- Markdown-formatted String.
29-- Markdown-formatted String.
30--
30--
31renderModulesAsMarkdown ::
31renderModulesAsMarkdown ::
32− (Functor m, Applicative m,
33− MonadError P.MultipleErrors m) =>
32+ (MonadError P.MultipleErrors m) =>
34 [P.Module] ->
33 [P.Module] ->
35 m String
34 m String
36renderModulesAsMarkdown =
35renderModulesAsMarkdown =
src/Language/PureScript/Docs/Convert.hs+6−6
@@ -38,7 +38,7 @@ import Language.PureScript.Docs.Convert.ReExports (updateReExports)
38-- documentation.
38-- documentation.
39--
39--
40convertModulesInPackage ::
40convertModulesInPackage ::
41− (Functor m, Applicative m, MonadError P.MultipleErrors m) =>
41+ (MonadError P.MultipleErrors m) =>
42 [InPackage P.Module] ->
42 [InPackage P.Module] ->
43 m [Module]
43 m [Module]
44convertModulesInPackage modules =
44convertModulesInPackage modules =
@@ -66,7 +66,7 @@ convertModulesInPackage modules =
66-- types.
66-- types.
67--
67--
68convertModules ::
68convertModules ::
69− (Functor m, Applicative m, MonadError P.MultipleErrors m) =>
69+ (MonadError P.MultipleErrors m) =>
70 [P.Module] ->
70 [P.Module] ->
71 m [Module]
71 m [Module]
72convertModules =
72convertModules =
@@ -81,7 +81,7 @@ importPrim = P.addDefaultImport (P.ModuleName [P.ProperName C.prim])
81-- Convert a sorted list of modules.
81-- Convert a sorted list of modules.
82--
82--
83convertSorted ::
83convertSorted ::
84− (Functor m, Applicative m, MonadError P.MultipleErrors m) =>
84+ (MonadError P.MultipleErrors m) =>
85 [P.Module] ->
85 [P.Module] ->
86 m [Module]
86 m [Module]
87convertSorted modules = do
87convertSorted modules = do
@@ -99,7 +99,7 @@ convertSorted modules = do
99-- types.
99-- types.
100--
100--
101typeCheckIfNecessary ::
101typeCheckIfNecessary ::
102− (Functor m, Applicative m, MonadError P.MultipleErrors m) =>
102+ (MonadError P.MultipleErrors m) =>
103 [P.Module] ->
103 [P.Module] ->
104 [Module] ->
104 [Module] ->
105 m [Module]
105 m [Module]
@@ -122,7 +122,7 @@ typeCheckIfNecessary modules convertedModules =
122-- were not provided.
122-- were not provided.
123--
123--
124typeCheck ::
124typeCheck ::
125− (Functor m, MonadError P.MultipleErrors m) =>
125+ (MonadError P.MultipleErrors m) =>
126 [P.Module] ->
126 [P.Module] ->
127 m ([P.Module], P.Environment)
127 m ([P.Module], P.Environment)
128typeCheck =
128typeCheck =
@@ -182,7 +182,7 @@ runParser p s = either (Left . show) Right $ do
182-- documentation information from.
182-- documentation information from.
183--
183--
184partiallyDesugar ::
184partiallyDesugar ::
185− (Functor m, Applicative m, MonadError P.MultipleErrors m) =>
185+ (MonadError P.MultipleErrors m) =>
186 [P.Module]
186 [P.Module]
187 -> m (P.Env, [P.Module])
187 -> m (P.Env, [P.Module])
188partiallyDesugar = P.evalSupplyT 0 . desugar'
188partiallyDesugar = P.evalSupplyT 0 . desugar'
src/Language/PureScript/Docs/Convert/ReExports.hs+13−22
@@ -69,8 +69,7 @@ updateReExports env order modules =
69-- have already been converted.
69-- have already been converted.
70--
70--
71getReExports ::
71getReExports ::
72− (Functor m, Applicative m,
73− MonadState (Map P.ModuleName Module) m) =>
72+ (MonadState (Map P.ModuleName Module) m) =>
74 P.Env ->
73 P.Env ->
75 P.ModuleName ->
74 P.ModuleName ->
76 m [(P.ModuleName, [Declaration])]
75 m [(P.ModuleName, [Declaration])]
@@ -105,9 +104,7 @@ getReExports env mn =
105-- class members are listed.
104-- class members are listed.
106--
105--
107collectDeclarations ::
106collectDeclarations ::
108− (Functor m, Applicative m,
109− MonadState (Map P.ModuleName Module) m,
107+ (MonadState (Map P.ModuleName Module) m, MonadReader P.ModuleName m) =>
110− MonadReader P.ModuleName m) =>
111 P.Imports ->
108 P.Imports ->
112 P.Exports ->
109 P.Exports ->
113 m [(P.ModuleName, [Declaration])]
110 m [(P.ModuleName, [Declaration])]
@@ -154,7 +151,7 @@ collectDeclarations imports exports = do
154-- instantiate @name@ as both 'P.Ident' and 'P.ProperName'.
151-- instantiate @name@ as both 'P.Ident' and 'P.ProperName'.
155--
152--
156findImport ::
153findImport ::
157− (Show name, Eq name, Applicative m, MonadReader P.ModuleName m) =>
154+ (Show name, Eq name, MonadReader P.ModuleName m) =>
158 [P.ImportRecord name] ->
155 [P.ImportRecord name] ->
159 (name, P.ModuleName) ->
156 (name, P.ModuleName) ->
160 m (P.ModuleName, name)
157 m (P.ModuleName, name)
@@ -174,9 +171,8 @@ findImport imps (name, orig) =
174 internalErrorInModule ("findImport: not found: " ++ show (name, orig))
171 internalErrorInModule ("findImport: not found: " ++ show (name, orig))
175
172
176lookupValueDeclaration ::
173lookupValueDeclaration ::
177− (Applicative m,
178− MonadState (Map P.ModuleName Module) m,
174+ (MonadState (Map P.ModuleName Module) m,
179− MonadReader P.ModuleName m) =>
175+ MonadReader P.ModuleName m) =>
180 P.ModuleName ->
176 P.ModuleName ->
181 P.Ident ->
177 P.Ident ->
182 m (P.ModuleName, [Either (String, P.Constraint, ChildDeclaration) Declaration])
178 m (P.ModuleName, [Either (String, P.Constraint, ChildDeclaration) Declaration])
@@ -233,9 +229,8 @@ lookupValueDeclaration importedFrom ident = do
233-- are only included in the output if they are listed in the arguments.
229-- are only included in the output if they are listed in the arguments.
234--
230--
235lookupTypeDeclaration ::
231lookupTypeDeclaration ::
236− (Applicative m,
237− MonadState (Map P.ModuleName Module) m,
232+ (MonadState (Map P.ModuleName Module) m,
238− MonadReader P.ModuleName m) =>
233+ MonadReader P.ModuleName m) =>
239 P.ModuleName ->
234 P.ModuleName ->
240 P.ProperName 'P.TypeName ->
235 P.ProperName 'P.TypeName ->
241 m (P.ModuleName, [Declaration])
236 m (P.ModuleName, [Declaration])
@@ -251,9 +246,8 @@ lookupTypeDeclaration importedFrom ty = do
251 ("lookupTypeDeclaration: unexpected result: " ++ show other)
246 ("lookupTypeDeclaration: unexpected result: " ++ show other)
252
247
253lookupTypeClassDeclaration ::
248lookupTypeClassDeclaration ::
254− (Applicative m,
255− MonadState (Map P.ModuleName Module) m,
249+ (MonadState (Map P.ModuleName Module) m,
256− MonadReader P.ModuleName m) =>
250+ MonadReader P.ModuleName m) =>
257 P.ModuleName ->
251 P.ModuleName ->
258 P.ProperName 'P.ClassName ->
252 P.ProperName 'P.ClassName ->
259 m (P.ModuleName, [Declaration])
253 m (P.ModuleName, [Declaration])
@@ -276,9 +270,8 @@ lookupTypeClassDeclaration importedFrom tyClass = do
276-- state, or raise an internal error if it is not there.
270-- state, or raise an internal error if it is not there.
277--
271--
278lookupModuleDeclarations ::
272lookupModuleDeclarations ::
279− (Applicative m,
280− MonadState (Map P.ModuleName Module) m,
273+ (MonadState (Map P.ModuleName Module) m,
281− MonadReader P.ModuleName m) =>
274+ MonadReader P.ModuleName m) =>
282 String ->
275 String ->
283 P.ModuleName ->
276 P.ModuleName ->
284 m [Declaration]
277 m [Declaration]
@@ -293,8 +286,7 @@ lookupModuleDeclarations definedIn moduleName = do
293 pure (allDeclarations mdl)
286 pure (allDeclarations mdl)
294
287
295handleTypeClassMembers ::
288handleTypeClassMembers ::
296− (Functor m, Applicative m,
297− MonadReader P.ModuleName m) =>
289+ (MonadReader P.ModuleName m) =>
298 Map P.ModuleName [Either (String, P.Constraint, ChildDeclaration) Declaration] ->
290 Map P.ModuleName [Either (String, P.Constraint, ChildDeclaration) Declaration] ->
299 Map P.ModuleName [Declaration] ->
291 Map P.ModuleName [Declaration] ->
300 m (Map P.ModuleName [Declaration], Map P.ModuleName [Declaration])
292 m (Map P.ModuleName [Declaration], Map P.ModuleName [Declaration])
@@ -364,8 +356,7 @@ instance Monoid TypeClassEnv where
364-- Returns a tuple of (values, type classes).
356-- Returns a tuple of (values, type classes).
365--
357--
366handleEnv ::
358handleEnv ::
367− (Functor m, Applicative m,
368− MonadReader P.ModuleName m) =>
359+ (MonadReader P.ModuleName m) =>
369 TypeClassEnv ->
360 TypeClassEnv ->
370 m ([Declaration], [Declaration])
361 m ([Declaration], [Declaration])
371handleEnv TypeClassEnv{..} =
362handleEnv TypeClassEnv{..} =
src/Language/PureScript/Docs/ParseAndBookmark.hs+2−2
@@ -35,7 +35,7 @@ import Language.PureScript.Docs.Convert (collectBookmarks)
35-- * Collect a list of bookmarks from the whole set of source files
35-- * Collect a list of bookmarks from the whole set of source files
36-- * Return the parsed modules and the bookmarks
36-- * Return the parsed modules and the bookmarks
37parseAndBookmark ::
37parseAndBookmark ::
38− (Functor m, Applicative m, MonadError P.MultipleErrors m, MonadIO m) =>
38+ (MonadError P.MultipleErrors m, MonadIO m) =>
39 [FilePath]
39 [FilePath]
40 -> [(PackageName, FilePath)]
40 -> [(PackageName, FilePath)]
41 -> m ([InPackage P.Module], [Bookmark])
41 -> m ([InPackage P.Module], [Bookmark])
@@ -82,7 +82,7 @@ fileInfoToString (FromDep _ fn) = fn
82parseFile :: FilePath -> IO (FilePath, String)
82parseFile :: FilePath -> IO (FilePath, String)
83parseFile input' = (,) input' <$> readFile input'
83parseFile input' = (,) input' <$> readFile input'
84
84
85−parseAs :: (Functor m, MonadIO m) => (FilePath -> a) -> FilePath -> m (a, String)
85+parseAs :: (MonadIO m) => (FilePath -> a) -> FilePath -> m (a, String)
86parseAs g = fmap (first g) . liftIO . parseFile
86parseAs g = fmap (first g) . liftIO . parseFile
87
87
88getDepsModuleNames :: [InPackage (FilePath, P.Module)] -> M.Map P.ModuleName PackageName
88getDepsModuleNames :: [InPackage (FilePath, P.Module)] -> M.Map P.ModuleName PackageName
src/Language/PureScript/Errors.hs+4−4
@@ -1283,7 +1283,7 @@ renderBox = unlines
1283rethrow :: (MonadError e m) => (e -> e) -> m a -> m a
1283rethrow :: (MonadError e m) => (e -> e) -> m a -> m a
1284rethrow f = flip catchError $ \e -> throwError (f e)
1284rethrow f = flip catchError $ \e -> throwError (f e)
1285
1285
1286−reifyErrors :: (Functor m, MonadError e m) => m a -> m (Either e a)
1286+reifyErrors :: (MonadError e m) => m a -> m (Either e a)
1287reifyErrors ma = catchError (fmap Right ma) (return . Left)
1287reifyErrors ma = catchError (fmap Right ma) (return . Left)
1288
1288
1289reflectErrors :: (MonadError e m) => m (Either e a) -> m a
1289reflectErrors :: (MonadError e m) => m (Either e a) -> m a
@@ -1310,13 +1310,13 @@ withPosition pos (ErrorMessage hints se) = ErrorMessage (PositionedError pos : h
1310-- |
1310-- |
1311-- Collect errors in in parallel
1311-- Collect errors in in parallel
1312--
1312--
1313−parU :: (MonadError MultipleErrors m, Functor m) => [a] -> (a -> m b) -> m [b]
1313+parU :: (MonadError MultipleErrors m) => [a] -> (a -> m b) -> m [b]
1314parU xs f = forM xs (withError . f) >>= collectErrors
1314parU xs f = forM xs (withError . f) >>= collectErrors
1315 where
1315 where
1316− withError :: (MonadError MultipleErrors m, Functor m) => m a -> m (Either MultipleErrors a)
1316+ withError :: (MonadError MultipleErrors m) => m a -> m (Either MultipleErrors a)
1317 withError u = catchError (Right <$> u) (return . Left)
1317 withError u = catchError (Right <$> u) (return . Left)
1318
1318
1319− collectErrors :: (MonadError MultipleErrors m, Functor m) => [Either MultipleErrors a] -> m [a]
1319+ collectErrors :: (MonadError MultipleErrors m) => [Either MultipleErrors a] -> m [a]
1320 collectErrors es = case lefts es of
1320 collectErrors es = case lefts es of
1321 [] -> return $ rights es
1321 [] -> return $ rights es
1322 errs -> throwError $ fold errs
1322 errs -> throwError $ fold errs
src/Language/PureScript/Ide.hs+3−3
@@ -74,12 +74,12 @@ findType :: (PscIde m, MonadLogger m) =>
74findType search filters =
74findType search filters =
75 CompletionResult . getExactMatches search filters <$> getAllModulesWithReexports
75 CompletionResult . getExactMatches search filters <$> getAllModulesWithReexports
76
76
77−findPursuitCompletions :: (Applicative m, MonadIO m, MonadLogger m) =>
77+findPursuitCompletions :: (MonadIO m, MonadLogger m) =>
78 PursuitQuery -> m Success
78 PursuitQuery -> m Success
79findPursuitCompletions (PursuitQuery q) =
79findPursuitCompletions (PursuitQuery q) =
80 PursuitResult <$> liftIO (searchPursuitForDeclarations q)
80 PursuitResult <$> liftIO (searchPursuitForDeclarations q)
81
81
82−findPursuitPackages :: (Applicative m, MonadIO m, MonadLogger m) =>
82+findPursuitPackages :: (MonadIO m, MonadLogger m) =>
83 PursuitQuery -> m Success
83 PursuitQuery -> m Success
84findPursuitPackages (PursuitQuery q) =
84findPursuitPackages (PursuitQuery q) =
85 PursuitResult <$> liftIO (findPackagesForModuleIdent q)
85 PursuitResult <$> liftIO (findPackagesForModuleIdent q)
@@ -118,7 +118,7 @@ caseSplit l b e csa t = do
118addClause :: Text -> CS.WildcardAnnotations -> Success
118addClause :: Text -> CS.WildcardAnnotations -> Success
119addClause t wca = MultilineTextResult (CS.addClause t wca)
119addClause t wca = MultilineTextResult (CS.addClause t wca)
120
120
121−importsForFile :: (Applicative m, MonadIO m, MonadLogger m, MonadError PscIdeError m) =>
121+importsForFile :: (MonadIO m, MonadLogger m, MonadError PscIdeError m) =>
122 FilePath -> m Success
122 FilePath -> m Success
123importsForFile fp = do
123importsForFile fp = do
124 imports <- getImportsForFile fp
124 imports <- getImportsForFile fp
src/Language/PureScript/Ide/CaseSplit.hs+1−10
@@ -60,15 +60,6 @@ caseSplit q = do
60 let appliedCtors = map (\(n, ts) -> (n, map applyTypeVars ts)) ctors
60 let appliedCtors = map (\(n, ts) -> (n, map applyTypeVars ts)) ctors
61 pure appliedCtors
61 pure appliedCtors
62
62
63−{- ["EDType {
64− edTypeName = ProperName {runProperName = \"Either\"}
65− , edTypeKind = FunKind Star (FunKind Star Star)
66− , edTypeDeclarationKind =
67− DataType [(\"a\",Just Star),(\"b\",Just Star)]
68− [(ProperName {runProperName = \"Left\"},[TypeVar \"a\"])
69− ,(ProperName {runProperName = \"Right\"},[TypeVar \"b\"])]}"]
70−-}
71−
72findTypeDeclaration :: (PscIde m, MonadLogger m, MonadError PscIdeError m) =>
63findTypeDeclaration :: (PscIde m, MonadLogger m, MonadError PscIdeError m) =>
73 ProperName 'TypeName -> m ExternsDeclaration
64 ProperName 'TypeName -> m ExternsDeclaration
74findTypeDeclaration q = do
65findTypeDeclaration q = do
@@ -87,7 +78,7 @@ findTypeDeclaration' t ExternsFile{..} =
87 EDType tn _ _ -> tn == t
78 EDType tn _ _ -> tn == t
88 _ -> False) efDeclarations
79 _ -> False) efDeclarations
89
80
90−splitTypeConstructor :: (Applicative m, MonadError PscIdeError m) =>
81+splitTypeConstructor :: (MonadError PscIdeError m) =>
91 Type -> m (ProperName 'TypeName, [Type])
82 Type -> m (ProperName 'TypeName, [Type])
92splitTypeConstructor = go []
83splitTypeConstructor = go []
93 where
84 where
src/Language/PureScript/Ide/Completion.hs+4−4
@@ -24,12 +24,12 @@ getExactMatches search filters modules =
24
24
25completionsFromModules :: [Module] -> [Completion]
25completionsFromModules :: [Module] -> [Completion]
26completionsFromModules = foldMap completionFromModule
26completionsFromModules = foldMap completionFromModule
27− where
27+ where
28− completionFromModule :: Module -> [Completion]
28+ completionFromModule :: Module -> [Completion]
29− completionFromModule (moduleIdent, decls) = mapMaybe (completionFromDecl moduleIdent) decls
29+ completionFromModule (moduleIdent, decls) = mapMaybe (completionFromDecl moduleIdent) decls
30
30
31completionFromDecl :: ModuleIdent -> ExternDecl -> Maybe Completion
31completionFromDecl :: ModuleIdent -> ExternDecl -> Maybe Completion
32completionFromDecl mi (FunctionDecl name type') = Just (Completion (mi, name, type'))
32completionFromDecl mi (FunctionDecl name type') = Just (Completion (mi, name, type'))
33completionFromDecl mi (DataDecl name kind) = Just (Completion (mi, name, kind))
33completionFromDecl mi (DataDecl name kind) = Just (Completion (mi, name, kind))
34−completionFromDecl _ (ModuleDecl name _) = Just (Completion ("module", name, "module"))
34+completionFromDecl _ (ModuleDecl name _) = Just (Completion ("module", name, "module"))
35completionFromDecl _ _ = Nothing
35completionFromDecl _ _ = Nothing
src/Language/PureScript/Ide/Error.hs+11−12
@@ -21,21 +21,20 @@ data PscIdeError
21
21
22instance ToJSON PscIdeError where
22instance ToJSON PscIdeError where
23 toJSON err = object
23 toJSON err = object
24− [
25− "resultType" .= ("error" :: Text),
24+ [ "resultType" .= ("error" :: Text)
26− "result" .= textError err
25+ , "result" .= textError err
27− ]
26+ ]
28
27
29textError :: PscIdeError -> Text
28textError :: PscIdeError -> Text
30−textError (GeneralError msg) = pack msg
29+textError (GeneralError msg) = pack msg
31−textError (NotFound ident) = "Symbol '" <> ident <> "' not found."
30+textError (NotFound ident) = "Symbol '" <> ident <> "' not found."
32−textError (ModuleNotFound ident) = "Module '" <> ident <> "' not found."
31+textError (ModuleNotFound ident) = "Module '" <> ident <> "' not found."
33−textError (ModuleFileNotFound ident) = "Extern file for module " <> ident <>" could not be found"
32+textError (ModuleFileNotFound ident) = "Extern file for module " <> ident <>" could not be found"
34−textError (ParseError parseError msg) = pack $ msg <> ": " <> show (escape parseError)
33+textError (ParseError parseError msg) = pack $ msg <> ": " <> show (escape parseError)
35− where
34+ where
36 -- escape newlines and other special chars so we can send the error over the socket as a single line
35 -- escape newlines and other special chars so we can send the error over the socket as a single line
37− escape :: P.ParseError -> String
36+ escape :: P.ParseError -> String
38− escape = show
37+ escape = show
39
38
40-- | Specialized version of `first` from `Data.Bifunctors`
39-- | Specialized version of `first` from `Data.Bifunctors`
41first :: (a -> b) -> Either a r -> Either b r
40first :: (a -> b) -> Either a r -> Either b r
src/Language/PureScript/Ide/Externs.hs+1−1
@@ -34,7 +34,7 @@ import Language.PureScript.Ide.Types
34import qualified Language.PureScript.Names as N
34import qualified Language.PureScript.Names as N
35import qualified Language.PureScript.Pretty as PP
35import qualified Language.PureScript.Pretty as PP
36
36
37−readExternFile :: (Applicative m, MonadIO m, MonadError PscIdeError m) =>
37+readExternFile :: (MonadIO m, MonadError PscIdeError m) =>
38 FilePath -> m PE.ExternsFile
38 FilePath -> m PE.ExternsFile
39readExternFile fp = do
39readExternFile fp = do
40 parseResult <- liftIO (decodeT <$> T.readFile fp)
40 parseResult <- liftIO (decodeT <$> T.readFile fp)
src/Language/PureScript/Ide/Matcher.hs+6−6
@@ -76,8 +76,8 @@ flexMatch pattern = mapMaybe (flexRate pattern)
76
76
77flexRate :: Text -> Completion -> Maybe ScoredCompletion
77flexRate :: Text -> Completion -> Maybe ScoredCompletion
78flexRate pattern c@(Completion (_,ident,_)) = do
78flexRate pattern c@(Completion (_,ident,_)) = do
79− score <- flexScore pattern ident
79+ score <- flexScore pattern ident
80− return (c, score)
80+ return (c, score)
81
81
82-- FlexMatching ala Sublime.
82-- FlexMatching ala Sublime.
83-- Borrowed from: http://cdewaka.com/2013/06/fuzzy-pattern-matching-in-haskell/
83-- Borrowed from: http://cdewaka.com/2013/06/fuzzy-pattern-matching-in-haskell/
@@ -88,13 +88,13 @@ flexRate pattern c@(Completion (_,ident,_)) = do
88flexScore :: Text -> DeclIdent -> Maybe Double
88flexScore :: Text -> DeclIdent -> Maybe Double
89flexScore "" _ = Nothing
89flexScore "" _ = Nothing
90flexScore pat str =
90flexScore pat str =
91− case TE.encodeUtf8 str =~ TE.encodeUtf8 pat' :: (Int, Int) of
91+ case TE.encodeUtf8 str =~ TE.encodeUtf8 pat' :: (Int, Int) of
92− (-1,0) -> Nothing
92+ (-1,0) -> Nothing
93− (start,len) -> Just $ calcScore start (start + len)
93+ (start,len) -> Just $ calcScore start (start + len)
94 where
94 where
95 Just (first,pattern) = T.uncons pat
95 Just (first,pattern) = T.uncons pat
96 -- This just interleaves the search string with .*
96 -- This just interleaves the search string with .*
97 -- abcd -> a.*b.*c.*d
97 -- abcd -> a.*b.*c.*d
98 pat' = first `T.cons` T.concatMap (T.snoc ".*") pattern
98 pat' = first `T.cons` T.concatMap (T.snoc ".*") pattern
99 calcScore start end =
99 calcScore start end =
100− 100.0 / fromIntegral ((1 + start) * (end - start + 1))
100+ 100.0 / fromIntegral ((1 + start) * (end - start + 1))
src/Language/PureScript/Ide/Pursuit.hs+11−11
@@ -10,9 +10,9 @@ import qualified Control.Exception as E
10import Data.Aeson
10import Data.Aeson
11import Data.ByteString (ByteString)
11import Data.ByteString (ByteString)
12import Data.ByteString.Lazy (fromStrict)
12import Data.ByteString.Lazy (fromStrict)
13−import Data.Foldable (toList)
13+import Data.Foldable (toList)
14+import Data.Maybe (mapMaybe)
14import Data.Monoid ((<>))
15import Data.Monoid ((<>))
15−import Data.Maybe (mapMaybe)
16import Data.String
16import Data.String
17import Data.Text (Text)
17import Data.Text (Text)
18import qualified Data.Text as T
18import qualified Data.Text as T
@@ -33,12 +33,12 @@ queryPursuit q = do
33 }
33 }
34 m <- newManager tlsManagerSettings
34 m <- newManager tlsManagerSettings
35 withHTTP req m $ \resp ->
35 withHTTP req m $ \resp ->
36− P.fold (\x a -> x <> a) "" id $ responseBody resp
36+ P.fold (<>) "" id $ responseBody resp
37
37
38
38
39handler :: HttpException -> IO [a]
39handler :: HttpException -> IO [a]
40−handler StatusCodeException{} = return []
40+handler StatusCodeException{} = pure []
41−handler _ = return []
41+handler _ = pure []
42
42
43searchPursuitForDeclarations :: Text -> IO [PursuitResponse]
43searchPursuitForDeclarations :: Text -> IO [PursuitResponse]
44searchPursuitForDeclarations query =
44searchPursuitForDeclarations query =
@@ -54,12 +54,12 @@ searchPursuitForDeclarations query =
54
54
55findPackagesForModuleIdent :: Text -> IO [PursuitResponse]
55findPackagesForModuleIdent :: Text -> IO [PursuitResponse]
56findPackagesForModuleIdent query =
56findPackagesForModuleIdent query =
57− (do r <- queryPursuit query
57+ (do r <- queryPursuit query
58− let results' = decode (fromStrict r) :: Maybe Array
58+ let results' = decode (fromStrict r) :: Maybe Array
59− case results' of
59+ case results' of
60− Nothing -> pure []
60+ Nothing -> pure []
61− Just results -> pure (mapMaybe isModuleResponse (map fromJSON (toList results)))) `E.catch`
61+ Just results -> pure (mapMaybe isModuleResponse (map fromJSON (toList results)))) `E.catch`
62− handler
62+ handler
63 where
63 where
64 isModuleResponse (Success a@ModuleResponse{}) = Just a
64 isModuleResponse (Success a@ModuleResponse{}) = Just a
65 isModuleResponse _ = Nothing
65 isModuleResponse _ = Nothing
src/Language/PureScript/Ide/Reexports.hs+21−19
@@ -15,10 +15,10 @@ import Language.PureScript.Ide.Types
15
15
16getReexports :: Module -> [ExternDecl]
16getReexports :: Module -> [ExternDecl]
17getReexports (mn, decls)= concatMap getExport decls
17getReexports (mn, decls)= concatMap getExport decls
18− where getExport d
18+ where getExport d
19− | (Export mn') <- d
19+ | (Export mn') <- d
20− , mn /= mn' = replaceExportWithAliases decls mn'
20+ , mn /= mn' = replaceExportWithAliases decls mn'
21− | otherwise = []
21+ | otherwise = []
22
22
23dependencyToExport :: ExternDecl -> ExternDecl
23dependencyToExport :: ExternDecl -> ExternDecl
24dependencyToExport (Dependency m _ _) = Export m
24dependencyToExport (Dependency m _ _) = Export m
@@ -51,23 +51,25 @@ removeExportDecls = fmap (filter (not . isExport))
51
51
52replaceReexports :: Module -> Map ModuleIdent [ExternDecl] -> Module
52replaceReexports :: Module -> Map ModuleIdent [ExternDecl] -> Module
53replaceReexports m db = result
53replaceReexports m db = result
54+ where
54− where reexports = getReexports m
55+ reexports = getReexports m
55− result = foldl go (removeExportDecls m) reexports
56+ result = foldl go (removeExportDecls m) reexports
56
57
57− go :: Module -> ExternDecl -> Module
58+ go :: Module -> ExternDecl -> Module
58− go m' re@(Export name) = replaceReexport re m' (getModule name)
59+ go m' re@(Export name) = replaceReexport re m' (getModule name)
59− go _ _ = error "partiality! woohoo"
60+ go _ _ = error "partiality! woohoo"
60
61
61− getModule :: ModuleIdent -> Module
62+ getModule :: ModuleIdent -> Module
62− getModule name = clean res
63+ getModule name = clean res
64+ where
63− where res = fromMaybe emptyModule $ (name , ) <$> Map.lookup name db
65+ res = fromMaybe emptyModule $ (name , ) <$> Map.lookup name db
64− -- we have to do this because keeping self exports in will result in
66+ -- we have to do this because keeping self exports in will result in
65− -- infinite loops
67+ -- infinite loops
66− clean (mn, decls) = (mn,) (filter (/= Export mn) decls)
68+ clean (mn, decls) = (mn,) (filter (/= Export mn) decls)
67
69
68resolveReexports :: Map ModuleIdent [ExternDecl] -> Module -> Module
70resolveReexports :: Map ModuleIdent [ExternDecl] -> Module -> Module
69−resolveReexports modules m = do
71+resolveReexports modules m =
70 let replaced = replaceReexports m modules
72 let replaced = replaceReexports m modules
71− if null . getReexports $ replaced
73+ in if null (getReexports replaced)
72− then replaced
74+ then replaced
73− else resolveReexports modules replaced
75+ else resolveReexports modules replaced
src/Language/PureScript/Ide/SourceFile.hs+40−40
@@ -3,8 +3,7 @@
3{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
4module Language.PureScript.Ide.SourceFile where
4module Language.PureScript.Ide.SourceFile where
5
5
6−import Prelude ()
6+import Prelude
7−import Prelude.Compat
8
7
9import Control.Monad.Error.Class
8import Control.Monad.Error.Class
10import Control.Monad.IO.Class
9import Control.Monad.IO.Class
@@ -22,7 +21,7 @@ import qualified Language.PureScript.Names as N
22import qualified Language.PureScript.Parser as P
21import qualified Language.PureScript.Parser as P
23import System.Directory
22import System.Directory
24
23
25−parseModuleFromFile :: (Applicative m, MonadIO m, MonadError PscIdeError m) =>
24+parseModuleFromFile :: (MonadIO m, MonadError PscIdeError m) =>
26 FilePath -> m D.Module
25 FilePath -> m D.Module
27parseModuleFromFile fp = do
26parseModuleFromFile fp = do
28 exists <- liftIO (doesFileExist fp)
27 exists <- liftIO (doesFileExist fp)
@@ -46,24 +45,25 @@ getImports (D.Module _ _ _ declarations _) =
46 isImport (D.PositionedDeclaration _ _ (i@D.ImportDeclaration{})) = Just i
45 isImport (D.PositionedDeclaration _ _ (i@D.ImportDeclaration{})) = Just i
47 isImport _ = Nothing
46 isImport _ = Nothing
48
47
49−getImportsForFile :: (Applicative m, MonadIO m, MonadError PscIdeError m) =>
48+getImportsForFile :: (MonadIO m, MonadError PscIdeError m) =>
50 FilePath -> m [ModuleImport]
49 FilePath -> m [ModuleImport]
51getImportsForFile fp = do
50getImportsForFile fp = do
52 module' <- parseModuleFromFile fp
51 module' <- parseModuleFromFile fp
53 let imports = getImports module'
52 let imports = getImports module'
54 pure (mkModuleImport . unwrapPositionedImport <$> imports)
53 pure (mkModuleImport . unwrapPositionedImport <$> imports)
54+ where
55− where mkModuleImport (D.ImportDeclaration mn importType' qualifier _) =
55+ mkModuleImport (D.ImportDeclaration mn importType' qualifier _) =
56− ModuleImport
56+ ModuleImport
57− (T.pack (N.runModuleName mn))
57+ (T.pack (N.runModuleName mn))
58− importType'
58+ importType'
59− (T.pack . N.runModuleName <$> qualifier)
59+ (T.pack . N.runModuleName <$> qualifier)
60− mkModuleImport _ = error "Shouldn't have gotten anything but Imports here"
60+ mkModuleImport _ = error "Shouldn't have gotten anything but Imports here"
61− unwrapPositionedImport (D.ImportDeclaration mn importType' qualifier b) =
61+ unwrapPositionedImport (D.ImportDeclaration mn importType' qualifier b) =
62− D.ImportDeclaration mn (unwrapImportType importType') qualifier b
62+ D.ImportDeclaration mn (unwrapImportType importType') qualifier b
63− unwrapPositionedImport x = x
63+ unwrapPositionedImport x = x
64− unwrapImportType (D.Explicit decls) = D.Explicit (map unwrapPositionedRef decls)
64+ unwrapImportType (D.Explicit decls) = D.Explicit (map unwrapPositionedRef decls)
65− unwrapImportType (D.Hiding decls) = D.Hiding (map unwrapPositionedRef decls)
65+ unwrapImportType (D.Hiding decls) = D.Hiding (map unwrapPositionedRef decls)
66− unwrapImportType D.Implicit = D.Implicit
66+ unwrapImportType D.Implicit = D.Implicit
67
67
68getPositionedImports :: D.Module -> [D.Declaration]
68getPositionedImports :: D.Module -> [D.Declaration]
69getPositionedImports (D.Module _ _ _ declarations _) =
69getPositionedImports (D.Module _ _ _ declarations _) =
@@ -73,34 +73,34 @@ getPositionedImports (D.Module _ _ _ declarations _) =
73 isImport _ = Nothing
73 isImport _ = Nothing
74
74
75getDeclPosition :: D.Module -> String -> Maybe SP.SourceSpan
75getDeclPosition :: D.Module -> String -> Maybe SP.SourceSpan
76−getDeclPosition m ident =
77− let decls = getDeclarations m
78− in getFirst (foldMap (match ident) decls)
76+getDeclPosition m ident = getFirst (foldMap (match ident) decls)
77+ where
78+ decls = getDeclarations m
79− where match q (D.PositionedDeclaration ss _ decl) = First (if go q decl
79+ match q (D.PositionedDeclaration ss _ decl) = First (if go q decl
80− then Just ss
80+ then Just ss
81− else Nothing)
81+ else Nothing)
82− match _ _ = First Nothing
82+ match _ _ = First Nothing
83
83
84− go q (D.DataDeclaration _ name _ constructors) =
84+ go q (D.DataDeclaration _ name _ constructors) =
85− properEqual name q || any (\(x,_) -> properEqual x q) constructors
85+ properEqual name q || any (\(x,_) -> properEqual x q) constructors
86− go q (D.DataBindingGroupDeclaration decls) = any (go q) decls
86+ go q (D.DataBindingGroupDeclaration decls') = any (go q) decls'
87− go q (D.TypeSynonymDeclaration name _ _) = properEqual name q
87+ go q (D.TypeSynonymDeclaration name _ _) = properEqual name q
88− go q (D.TypeDeclaration ident' _) = identEqual ident' q
88+ go q (D.TypeDeclaration ident' _) = identEqual ident' q
89− go q (D.ValueDeclaration ident' _ _ _) = identEqual ident' q
89+ go q (D.ValueDeclaration ident' _ _ _) = identEqual ident' q
90− go q (D.ExternDeclaration ident' _) = identEqual ident' q
90+ go q (D.ExternDeclaration ident' _) = identEqual ident' q
91− go q (D.ExternDataDeclaration name _) = properEqual name q
91+ go q (D.ExternDataDeclaration name _) = properEqual name q
92− go q (D.TypeClassDeclaration name _ _ members) =
92+ go q (D.TypeClassDeclaration name _ _ members) =
93− properEqual name q || any (go q . unwrapPositioned) members
93+ properEqual name q || any (go q . unwrapPositioned) members
94− go q (D.TypeInstanceDeclaration ident' _ _ _ _) =
94+ go q (D.TypeInstanceDeclaration ident' _ _ _ _) =
95− identEqual ident' q
95+ identEqual ident' q
96− go _ _ = False
96+ go _ _ = False
97
97
98− properEqual x q = N.runProperName x == q
98+ properEqual x q = N.runProperName x == q
99− identEqual x q = N.runIdent x == q
99+ identEqual x q = N.runIdent x == q
100
100
101goToDefinition :: String -> FilePath -> IO (Maybe SP.SourceSpan)
101goToDefinition :: String -> FilePath -> IO (Maybe SP.SourceSpan)
102goToDefinition q fp = do
102goToDefinition q fp = do
103 m <- runExceptT (parseModuleFromFile fp)
103 m <- runExceptT (parseModuleFromFile fp)
104 case m of
104 case m of
105− Right module' -> return $ getDeclPosition module' q
105+ Right module' -> pure (getDeclPosition module' q)
106− Left _ -> return Nothing
106+ Left _ -> pure Nothing
src/Language/PureScript/Ide/State.hs+10−10
@@ -25,38 +25,38 @@ import Language.PureScript.Ide.Reexports
25import Language.PureScript.Ide.Types
25import Language.PureScript.Ide.Types
26import Language.PureScript.Names
26import Language.PureScript.Names
27
27
28−getPscIdeState :: (PscIde m, Functor m) =>
28+getPscIdeState :: (PscIde m) =>
29 m (M.Map ModuleIdent [ExternDecl])
29 m (M.Map ModuleIdent [ExternDecl])
30getPscIdeState = do
30getPscIdeState = do
31 stateVar <- envStateVar <$> ask
31 stateVar <- envStateVar <$> ask
32 liftIO $ pscStateModules <$> readTVarIO stateVar
32 liftIO $ pscStateModules <$> readTVarIO stateVar
33
33
34−getExternFiles :: (PscIde m, Functor m) =>
34+getExternFiles :: (PscIde m) =>
35 m (M.Map ModuleName ExternsFile)
35 m (M.Map ModuleName ExternsFile)
36getExternFiles = do
36getExternFiles = do
37 stateVar <- envStateVar <$> ask
37 stateVar <- envStateVar <$> ask
38 liftIO (externsFiles <$> readTVarIO stateVar)
38 liftIO (externsFiles <$> readTVarIO stateVar)
39
39
40−getAllDecls :: (PscIde m, Functor m) => m [ExternDecl]
40+getAllDecls :: (PscIde m) => m [ExternDecl]
41getAllDecls = concat <$> getPscIdeState
41getAllDecls = concat <$> getPscIdeState
42
42
43−getAllModules :: (PscIde m, Functor m) => m [Module]
43+getAllModules :: (PscIde m) => m [Module]
44getAllModules = M.toList <$> getPscIdeState
44getAllModules = M.toList <$> getPscIdeState
45
45
46−getAllModulesWithReexports :: (PscIde m, MonadLogger m, Applicative m) =>
46+getAllModulesWithReexports :: (PscIde m, MonadLogger m) =>
47 m [Module]
47 m [Module]
48getAllModulesWithReexports = do
48getAllModulesWithReexports = do
49 mis <- M.keys <$> getPscIdeState
49 mis <- M.keys <$> getPscIdeState
50 ms <- traverse getModuleWithReexports mis
50 ms <- traverse getModuleWithReexports mis
51 pure (catMaybes ms)
51 pure (catMaybes ms)
52
52
53−getModule :: (PscIde m, MonadLogger m, Applicative m) =>
53+getModule :: (PscIde m, MonadLogger m) =>
54 ModuleIdent -> m (Maybe Module)
54 ModuleIdent -> m (Maybe Module)
55getModule m = do
55getModule m = do
56 modules <- getPscIdeState
56 modules <- getPscIdeState
57 pure ((m,) <$> M.lookup m modules)
57 pure ((m,) <$> M.lookup m modules)
58
58
59−getModuleWithReexports :: (PscIde m, MonadLogger m, Applicative m) =>
59+getModuleWithReexports :: (PscIde m, MonadLogger m) =>
60 ModuleIdent -> m (Maybe Module)
60 ModuleIdent -> m (Maybe Module)
61getModuleWithReexports mi = do
61getModuleWithReexports mi = do
62 m <- getModule mi
62 m <- getModule mi
@@ -73,8 +73,8 @@ insertModule externsFile = do
73
73
74insertModule' :: TVar PscIdeState -> ExternsFile -> STM ()
74insertModule' :: TVar PscIdeState -> ExternsFile -> STM ()
75insertModule' st ef = do
75insertModule' st ef = do
76− modifyTVar (st) $ \x ->
76+ modifyTVar st $ \x ->
77 x { externsFiles = M.insert (efModuleName ef) ef (externsFiles x)
77 x { externsFiles = M.insert (efModuleName ef) ef (externsFiles x)
78− , pscStateModules = let (mn, decls ) = convertExterns ef
78+ , pscStateModules = let (mn, decls) = convertExterns ef
79− in M.insert mn decls (pscStateModules x)
79+ in M.insert mn decls (pscStateModules x)
80 }
80 }
src/Language/PureScript/Ide/Types.hs+76−78
@@ -33,21 +33,26 @@ type Type = Text
33data Fixity = Infix | Infixl | Infixr deriving(Show, Eq, Ord)
33data Fixity = Infix | Infixl | Infixr deriving(Show, Eq, Ord)
34
34
35data ExternDecl
35data ExternDecl
36+ -- | A function/value declaration
36− = FunctionDecl { functionName :: DeclIdent
37+ = FunctionDecl
37− , functionType :: Type
38+ DeclIdent -- The functions name
38− }
39+ Type -- The functions type
39− | FixityDeclaration Fixity
40+ | FixityDeclaration Fixity Int DeclIdent
40− Int
41+ -- | A Dependency onto another Module
41− DeclIdent
42+ | Dependency
42− | Dependency { dependencyModule :: ModuleIdent
43+ ModuleIdent -- name of the dependency
43− , dependencyNames :: [Text]
44+ [Text] -- explicit imports
44− , dependencyAlias :: Maybe Text
45+ (Maybe Text) -- An eventual qualifier
45− }
46+
47+ -- | A module declaration
46− | ModuleDecl ModuleIdent
48+ | ModuleDecl
49+ ModuleIdent -- The modules name
47− [DeclIdent]
50+ [DeclIdent] -- The exported identifiers
51+ -- | A data/newtype declaration
48− | DataDecl DeclIdent
52+ | DataDecl DeclIdent -- The type name
49− Text
53+ Text -- The "type"
54+ -- | An exported module
50− | Export ModuleIdent
55+ | Export ModuleIdent -- The exported Modules name
51 deriving (Show,Eq,Ord)
56 deriving (Show,Eq,Ord)
52
57
53instance ToJSON ExternDecl where
58instance ToJSON ExternDecl where
@@ -63,22 +68,22 @@ instance ToJSON ExternDecl where
63type Module = (ModuleIdent, [ExternDecl])
68type Module = (ModuleIdent, [ExternDecl])
64
69
65data Configuration =
70data Configuration =
66− Configuration {
71+ Configuration
67− confOutputPath :: FilePath
72+ { confOutputPath :: FilePath
68 , confDebug :: Bool
73 , confDebug :: Bool
69 }
74 }
70
75
71data PscIdeEnvironment =
76data PscIdeEnvironment =
72− PscIdeEnvironment {
77+ PscIdeEnvironment
73− envStateVar :: TVar PscIdeState
78+ { envStateVar :: TVar PscIdeState
74 , envConfiguration :: Configuration
79 , envConfiguration :: Configuration
75 }
80 }
76
81
77−type PscIde m = (Applicative m, MonadIO m, MonadReader PscIdeEnvironment m)
82+type PscIde m = (MonadIO m, MonadReader PscIdeEnvironment m)
78
83
79data PscIdeState =
84data PscIdeState =
80− PscIdeState {
85+ PscIdeState
81− pscStateModules :: M.Map Text [ExternDecl]
86+ { pscStateModules :: M.Map Text [ExternDecl]
82 , externsFiles :: M.Map ModuleName ExternsFile
87 , externsFiles :: M.Map ModuleName ExternsFile
83 } deriving Show
88 } deriving Show
84
89
@@ -90,29 +95,32 @@ newtype Completion =
90 deriving (Show,Eq)
95 deriving (Show,Eq)
91
96
92data ModuleImport =
97data ModuleImport =
93− ModuleImport {
98+ ModuleImport
94− importModuleName :: ModuleIdent
99+ { importModuleName :: ModuleIdent
95 , importType :: D.ImportDeclarationType
100 , importType :: D.ImportDeclarationType
96 , importQualifier :: Maybe Text
101 , importQualifier :: Maybe Text
97 } deriving(Show)
102 } deriving(Show)
98
103
99instance Eq ModuleImport where
104instance Eq ModuleImport where
105+ mi1 == mi2 =
100− mi1 == mi2 = importModuleName mi1 == importModuleName mi2
106+ importModuleName mi1 == importModuleName mi2
101− && importQualifier mi1 == importQualifier mi2
107+ && importQualifier mi1 == importQualifier mi2
102
108
103instance ToJSON ModuleImport where
109instance ToJSON ModuleImport where
104 toJSON (ModuleImport mn D.Implicit qualifier) =
110 toJSON (ModuleImport mn D.Implicit qualifier) =
105− object $ ["module" .= mn
111+ object $ [ "module" .= mn
106− , "importType" .= ("implicit" :: Text)
112+ , "importType" .= ("implicit" :: Text)
107− ] ++ fmap (\x -> "qualifier" .= x) (maybeToList qualifier)
113+ ] ++ fmap (\x -> "qualifier" .= x) (maybeToList qualifier)
108 toJSON (ModuleImport mn (D.Explicit refs) _) =
114 toJSON (ModuleImport mn (D.Explicit refs) _) =
109− object ["module" .= mn
115+ object [ "module" .= mn
110 , "importType" .= ("explicit" :: Text)
116 , "importType" .= ("explicit" :: Text)
111− , "identifiers" .= (identifierFromDeclarationRef <$> refs)]
117+ , "identifiers" .= (identifierFromDeclarationRef <$> refs)
118+ ]
112 toJSON (ModuleImport mn (D.Hiding refs) _) =
119 toJSON (ModuleImport mn (D.Hiding refs) _) =
113− object ["module" .= mn
120+ object [ "module" .= mn
114 , "importType" .= ("hiding" :: Text)
121 , "importType" .= ("hiding" :: Text)
115− , "identifiers" .= (identifierFromDeclarationRef <$> refs)]
122+ , "identifiers" .= (identifierFromDeclarationRef <$> refs)
123+ ]
116
124
117identifierFromDeclarationRef :: D.DeclarationRef -> String
125identifierFromDeclarationRef :: D.DeclarationRef -> String
118identifierFromDeclarationRef (D.TypeRef name _) = N.runProperName name
126identifierFromDeclarationRef (D.TypeRef name _) = N.runProperName name
@@ -121,16 +129,16 @@ identifierFromDeclarationRef (D.TypeClassRef name) = N.runProperName name
121identifierFromDeclarationRef _ = ""
129identifierFromDeclarationRef _ = ""
122
130
123instance FromJSON Completion where
131instance FromJSON Completion where
124− parseJSON (Object o) = do
132+ parseJSON (Object o) = do
125− m <- o .: "module"
133+ m <- o .: "module"
126− d <- o .: "identifier"
134+ d <- o .: "identifier"
127− t <- o .: "type"
135+ t <- o .: "type"
128− return $ Completion (m, d, t)
136+ pure (Completion (m, d, t))
129− parseJSON _ = mzero
137+ parseJSON _ = mzero
130
138
131instance ToJSON Completion where
139instance ToJSON Completion where
132− toJSON (Completion (m,d,t)) =
140+ toJSON (Completion (m,d,t)) =
133− object ["module" .= m, "identifier" .= d, "type" .= t]
141+ object ["module" .= m, "identifier" .= d, "type" .= t]
134
142
135data Success =
143data Success =
136 CompletionResult [Completion]
144 CompletionResult [Completion]
@@ -161,23 +169,22 @@ data PursuitSearchType = Package | Identifier
161
169
162instance FromJSON PursuitSearchType where
170instance FromJSON PursuitSearchType where
163 parseJSON (String t) = case t of
171 parseJSON (String t) = case t of
164− "package" -> return Package
172+ "package" -> pure Package
165− "completion" -> return Identifier
173+ "completion" -> pure Identifier
166 _ -> mzero
174 _ -> mzero
167 parseJSON _ = mzero
175 parseJSON _ = mzero
168
176
169instance FromJSON PursuitQuery where
177instance FromJSON PursuitQuery where
170− parseJSON o = fmap PursuitQuery (parseJSON o)
178+ parseJSON o = PursuitQuery <$> (parseJSON o)
171−
179+
172−data PursuitResponse
180+data PursuitResponse =
181+ -- | A Pursuit Response for a module. Consists of the modules name and the
182+ -- package it belongs to
173− = ModuleResponse { moduleResponseName :: Text
183+ ModuleResponse ModuleIdent Text
174− , moduleResponsePackage :: Text}
184+ -- | A Pursuit Response for a declaration. Consist of the declarations type,
185+ -- module, name and package
175− | DeclarationResponse { declarationResponseType :: Text
186+ | DeclarationResponse Type ModuleIdent DeclIdent Text
176− , declarationResponseModule :: Text
177− , declarationResponseIdent :: Text
178− , declarationResponsePackage :: Text
179− }
180− deriving (Show,Eq)
187+ deriving (Show,Eq)
181
188
182instance FromJSON PursuitResponse where
189instance FromJSON PursuitResponse where
183 parseJSON (Object o) = do
190 parseJSON (Object o) = do
@@ -186,22 +193,12 @@ instance FromJSON PursuitResponse where
186 (type' :: String) <- info .: "type"
193 (type' :: String) <- info .: "type"
187 case type' of
194 case type' of
188 "module" -> do
195 "module" -> do
189− name <- info .: "module"
196+ name <- info .: "module"
190− return
191− ModuleResponse
197+ pure (ModuleResponse name package)
192− { moduleResponseName = name
193− , moduleResponsePackage = package
194− }
195 "declaration" -> do
198 "declaration" -> do
196− moduleName <- info .: "module"
199+ moduleName <- info .: "module"
197− Right (ident, declType) <- typeParse <$> o .: "text"
200+ Right (ident, declType) <- typeParse <$> o .: "text"
198− return
199− DeclarationResponse
201+ pure (DeclarationResponse declType moduleName ident package)
200− { declarationResponseType = declType
201− , declarationResponseModule = moduleName
202− , declarationResponseIdent = ident
203− , declarationResponsePackage = package
204− }
205 _ -> mzero
202 _ -> mzero
206 parseJSON _ = mzero
203 parseJSON _ = mzero
207
204
@@ -217,7 +214,7 @@ typeParse t = case parse parseType "" t of
217 _ <- string "::"
214 _ <- string "::"
218 spaces
215 spaces
219 type' <- many1 anyChar
216 type' <- many1 anyChar
220− return (unpack name, type')
217+ pure (unpack name, type')
221
218
222identifier :: Parser Text
219identifier :: Parser Text
223identifier = do
220identifier = do
@@ -227,14 +224,15 @@ identifier = do
227 between (char '(') (char ')') (many1 (noneOf ", )")) <|>
224 between (char '(') (char ')') (many1 (noneOf ", )")) <|>
228 many1 (noneOf ", )")
225 many1 (noneOf ", )")
229 spaces
226 spaces
230− return (pack ident)
227+ pure (pack ident)
231
228
232instance ToJSON PursuitResponse where
229instance ToJSON PursuitResponse where
233− toJSON ModuleResponse{..} =
230+ toJSON (ModuleResponse name package) =
234− object ["module" .= moduleResponseName, "package" .= moduleResponsePackage]
231+ object ["module" .= name, "package" .= package]
235− toJSON DeclarationResponse{..} =
232+ toJSON (DeclarationResponse module' ident type' package) =
236 object
233 object
237− [ "module" .= declarationResponseModule
234+ [ "module" .= module'
238− , "ident" .= declarationResponseIdent
235+ , "ident" .= ident
239− , "type" .= declarationResponseType
236+ , "type" .= type'
240− , "package" .= declarationResponsePackage]
237+ , "package" .= package
238+ ]
src/Language/PureScript/Kinds.hs+1−1
@@ -42,7 +42,7 @@ everywhereOnKinds f = go
42 go (FunKind k1 k2) = f (FunKind (go k1) (go k2))
42 go (FunKind k1 k2) = f (FunKind (go k1) (go k2))
43 go other = f other
43 go other = f other
44
44
45−everywhereOnKindsM :: (Functor m, Applicative m, Monad m) => (Kind -> m Kind) -> Kind -> m Kind
45+everywhereOnKindsM :: Monad m => (Kind -> m Kind) -> Kind -> m Kind
46everywhereOnKindsM f = go
46everywhereOnKindsM f = go
47 where
47 where
48 go (Row k1) = (Row <$> go k1) >>= f
48 go (Row k1) = (Row <$> go k1) >>= f
src/Language/PureScript/Linter.hs+1−1
@@ -29,7 +29,7 @@ import Language.PureScript.Linter.Imports as L
29-- | Lint the PureScript AST.
29-- | Lint the PureScript AST.
30-- |
30-- |
31-- | Right now, this pass only performs a shadowing check.
31-- | Right now, this pass only performs a shadowing check.
32−lint :: forall m. (Applicative m, MonadWriter MultipleErrors m) => Module -> m ()
32+lint :: forall m. (MonadWriter MultipleErrors m) => Module -> m ()
33lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDeclaration ds
33lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDeclaration ds
34 where
34 where
35 moduleNames :: S.Set Ident
35 moduleNames :: S.Set Ident
src/Language/PureScript/Linter/Exhaustive.hs+2−2
@@ -261,7 +261,7 @@ checkExhaustive hasConstraint env mn numArgs cas = makeResult . first nub $ fold
261-- |
261-- |
262-- Exhaustivity checking over a list of declarations
262-- Exhaustivity checking over a list of declarations
263--
263--
264−checkExhaustiveDecls :: forall m. (Applicative m, MonadWriter MultipleErrors m) => Environment -> ModuleName -> [Declaration] -> m ()
264+checkExhaustiveDecls :: forall m. MonadWriter MultipleErrors m => Environment -> ModuleName -> [Declaration] -> m ()
265checkExhaustiveDecls env mn = mapM_ onDecl
265checkExhaustiveDecls env mn = mapM_ onDecl
266 where
266 where
267 onDecl :: Declaration -> m ()
267 onDecl :: Declaration -> m ()
@@ -310,5 +310,5 @@ checkExhaustiveDecls env mn = mapM_ onDecl
310-- |
310-- |
311-- Exhaustivity checking over a single module
311-- Exhaustivity checking over a single module
312--
312--
313−checkExhaustiveModule :: forall m. (Applicative m, MonadWriter MultipleErrors m) => Environment -> Module -> m ()
313+checkExhaustiveModule :: forall m. MonadWriter MultipleErrors m => Environment -> Module -> m ()
314checkExhaustiveModule env (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ checkExhaustiveDecls env mn ds
314checkExhaustiveModule env (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ checkExhaustiveDecls env mn ds
src/Language/PureScript/Linter/Imports.hs+2−2
@@ -70,7 +70,7 @@ type UsedImports = M.Map ModuleName [Name]
70--
70--
71lintImports
71lintImports
72 :: forall m
72 :: forall m
73− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
73+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
74 => Module
74 => Module
75 -> Env
75 -> Env
76 -> UsedImports
76 -> UsedImports
@@ -170,7 +170,7 @@ lintImports (Module _ _ mn mdecls mexports) env usedImps = do
170
170
171lintImportDecl
171lintImportDecl
172 :: forall m
172 :: forall m
173− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
173+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
174 => Env
174 => Env
175 -> ModuleName
175 -> ModuleName
176 -> Maybe ModuleName
176 -> Maybe ModuleName
src/Language/PureScript/Make.hs+1−1
@@ -145,7 +145,7 @@ data RebuildPolicy
145-- If timestamps have not changed, the externs file can be used to provide the module's types without
145-- If timestamps have not changed, the externs file can be used to provide the module's types without
146-- having to typecheck the module again.
146-- having to typecheck the module again.
147--
147--
148−make :: forall m. (Functor m, Applicative m, Monad m, MonadBaseControl IO m, MonadReader Options m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
148+make :: forall m. (Monad m, MonadBaseControl IO m, MonadReader Options m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
149 => MakeActions m
149 => MakeActions m
150 -> [Module]
150 -> [Module]
151 -> m Environment
151 -> m Environment
src/Language/PureScript/Parser/Declarations.hs+1−1
@@ -261,7 +261,7 @@ parseModule = do
261 return $ Module ss comments name decls exports
261 return $ Module ss comments name decls exports
262
262
263-- | Parse a collection of modules in parallel
263-- | Parse a collection of modules in parallel
264−parseModulesFromFiles :: forall m k. (MonadError MultipleErrors m, Functor m) =>
264+parseModulesFromFiles :: forall m k. (MonadError MultipleErrors m) =>
265 (k -> FilePath) -> [(k, String)] -> m [(k, Module)]
265 (k -> FilePath) -> [(k, String)] -> m [(k, Module)]
266parseModulesFromFiles toFilePath input = do
266parseModulesFromFiles toFilePath input = do
267 modules <- flip parU id $ map wrapError $ inParallel $ flip map input $ \(k, content) -> do
267 modules <- flip parU id $ map wrapError $ inParallel $ flip map input $ \(k, content) -> do
src/Language/PureScript/Parser/JS.hs+1−1
@@ -36,7 +36,7 @@ import qualified Text.Parsec as PS
36
36
37type ForeignJS = String
37type ForeignJS = String
38
38
39−parseForeignModulesFromFiles :: (Functor m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
39+parseForeignModulesFromFiles :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
40 => [(FilePath, ForeignJS)]
40 => [(FilePath, ForeignJS)]
41 -> m (M.Map ModuleName FilePath)
41 -> m (M.Map ModuleName FilePath)
42parseForeignModulesFromFiles files = do
42parseForeignModulesFromFiles files = do
src/Language/PureScript/Sugar.hs+1−1
@@ -63,7 +63,7 @@ import Language.PureScript.Sugar.TypeDeclarations as S
63--
63--
64-- * Group mutually recursive value and data declarations into binding groups.
64-- * Group mutually recursive value and data declarations into binding groups.
65--
65--
66−desugar :: (Applicative m, MonadSupply m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) => [ExternsFile] -> [Module] -> m [Module]
66+desugar :: (MonadSupply m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) => [ExternsFile] -> [Module] -> m [Module]
67desugar externs =
67desugar externs =
68 map removeSignedLiterals
68 map removeSignedLiterals
69 >>> traverse desugarObjectConstructors
69 >>> traverse desugarObjectConstructors
src/Language/PureScript/Sugar/BindingGroups.hs+3−3
@@ -35,7 +35,7 @@ import Language.PureScript.Types
35-- Replace all sets of mutually-recursive declarations in a module with binding groups
35-- Replace all sets of mutually-recursive declarations in a module with binding groups
36--
36--
37createBindingGroupsModule
37createBindingGroupsModule
38− :: (Functor m, Applicative m, MonadError MultipleErrors m)
38+ :: (MonadError MultipleErrors m)
39 => [Module]
39 => [Module]
40 -> m [Module]
40 -> m [Module]
41createBindingGroupsModule =
41createBindingGroupsModule =
@@ -52,7 +52,7 @@ collapseBindingGroupsModule =
52
52
53createBindingGroups
53createBindingGroups
54 :: forall m
54 :: forall m
55− . (Functor m, Applicative m, MonadError MultipleErrors m)
55+ . (MonadError MultipleErrors m)
56 => ModuleName
56 => ModuleName
57 -> [Declaration]
57 -> [Declaration]
58 -> m [Declaration]
58 -> m [Declaration]
@@ -171,7 +171,7 @@ getTypeName _ = internalError "Expected DataDeclaration"
171--
171--
172toBindingGroup
172toBindingGroup
173 :: forall m
173 :: forall m
174− . (Functor m, MonadError MultipleErrors m)
174+ . (MonadError MultipleErrors m)
175 => ModuleName
175 => ModuleName
176 -> SCC Declaration
176 -> SCC Declaration
177 -> m Declaration
177 -> m Declaration
src/Language/PureScript/Sugar/CaseDeclarations.hs+6−6
@@ -36,7 +36,7 @@ isLeft (Right _) = False
36-- |
36-- |
37-- Replace all top-level binders in a module with case expressions.
37-- Replace all top-level binders in a module with case expressions.
38--
38--
39−desugarCasesModule :: (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m) => [Module] -> m [Module]
39+desugarCasesModule :: (MonadSupply m, MonadError MultipleErrors m) => [Module] -> m [Module]
40desugarCasesModule ms = forM ms $ \(Module ss coms name ds exps) ->
40desugarCasesModule ms = forM ms $ \(Module ss coms name ds exps) ->
41 rethrow (addHint (ErrorInModule name)) $
41 rethrow (addHint (ErrorInModule name)) $
42 Module ss coms name <$> (desugarCases <=< desugarAbs <=< validateCases $ ds) <*> pure exps
42 Module ss coms name <$> (desugarCases <=< desugarAbs <=< validateCases $ ds) <*> pure exps
@@ -44,7 +44,7 @@ desugarCasesModule ms = forM ms $ \(Module ss coms name ds exps) ->
44-- |
44-- |
45-- Validates that case head and binder lengths match.
45-- Validates that case head and binder lengths match.
46--
46--
47−validateCases :: forall m. (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
47+validateCases :: forall m. (MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
48validateCases = flip parU f
48validateCases = flip parU f
49 where
49 where
50 (f, _, _) = everywhereOnValuesM return validate return
50 (f, _, _) = everywhereOnValuesM return validate return
@@ -69,7 +69,7 @@ validateCases = flip parU f
69 positionedBinder (PositionedBinder p _ _) = Just p
69 positionedBinder (PositionedBinder p _ _) = Just p
70 positionedBinder _ = Nothing
70 positionedBinder _ = Nothing
71
71
72−desugarAbs :: forall m. (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
72+desugarAbs :: forall m. (MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
73desugarAbs = flip parU f
73desugarAbs = flip parU f
74 where
74 where
75 (f, _, _) = everywhereOnValuesM return replace return
75 (f, _, _) = everywhereOnValuesM return replace return
@@ -83,7 +83,7 @@ desugarAbs = flip parU f
83-- |
83-- |
84-- Replace all top-level binders with case expressions.
84-- Replace all top-level binders with case expressions.
85--
85--
86−desugarCases :: forall m. (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
86+desugarCases :: forall m. (MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
87desugarCases = desugarRest <=< fmap join . flip parU toDecls . groupBy inSameGroup
87desugarCases = desugarRest <=< fmap join . flip parU toDecls . groupBy inSameGroup
88 where
88 where
89 desugarRest :: [Declaration] -> m [Declaration]
89 desugarRest :: [Declaration] -> m [Declaration]
@@ -109,7 +109,7 @@ inSameGroup (PositionedDeclaration _ _ d1) d2 = inSameGroup d1 d2
109inSameGroup d1 (PositionedDeclaration _ _ d2) = inSameGroup d1 d2
109inSameGroup d1 (PositionedDeclaration _ _ d2) = inSameGroup d1 d2
110inSameGroup _ _ = False
110inSameGroup _ _ = False
111
111
112−toDecls :: forall m. (Functor m, Applicative m, Monad m, MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
112+toDecls :: forall m. (MonadSupply m, MonadError MultipleErrors m) => [Declaration] -> m [Declaration]
113toDecls [ValueDeclaration ident nameKind bs (Right val)] | all isVarBinder bs = do
113toDecls [ValueDeclaration ident nameKind bs (Right val)] | all isVarBinder bs = do
114 args <- mapM fromVarBinder bs
114 args <- mapM fromVarBinder bs
115 let body = foldr (Abs . Left) val args
115 let body = foldr (Abs . Left) val args
@@ -147,7 +147,7 @@ toTuple (ValueDeclaration _ _ bs result) = (bs, result)
147toTuple (PositionedDeclaration _ _ d) = toTuple d
147toTuple (PositionedDeclaration _ _ d) = toTuple d
148toTuple _ = internalError "Not a value declaration"
148toTuple _ = internalError "Not a value declaration"
149
149
150−makeCaseDeclaration :: forall m. (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m) => Ident -> [([Binder], Either [(Guard, Expr)] Expr)] -> m Declaration
150+makeCaseDeclaration :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Ident -> [([Binder], Either [(Guard, Expr)] Expr)] -> m Declaration
151makeCaseDeclaration ident alternatives = do
151makeCaseDeclaration ident alternatives = do
152 let namedArgs = map findName . fst <$> alternatives
152 let namedArgs = map findName . fst <$> alternatives
153 argNames = foldl1 resolveNames namedArgs
153 argNames = foldl1 resolveNames namedArgs
src/Language/PureScript/Sugar/DoNotation.hs+2−2
@@ -26,10 +26,10 @@ import Control.Monad.Supply.Class
26-- Replace all @DoNotationBind@ and @DoNotationValue@ constructors with applications of the Prelude.bind function,
26-- Replace all @DoNotationBind@ and @DoNotationValue@ constructors with applications of the Prelude.bind function,
27-- and all @DoNotationLet@ constructors with let expressions.
27-- and all @DoNotationLet@ constructors with let expressions.
28--
28--
29−desugarDoModule :: forall m. (Applicative m, MonadSupply m, MonadError MultipleErrors m) => Module -> m Module
29+desugarDoModule :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Module -> m Module
30desugarDoModule (Module ss coms mn ds exts) = Module ss coms mn <$> parU ds desugarDo <*> pure exts
30desugarDoModule (Module ss coms mn ds exts) = Module ss coms mn <$> parU ds desugarDo <*> pure exts
31
31
32−desugarDo :: forall m. (Applicative m, MonadSupply m, MonadError MultipleErrors m) => Declaration -> m Declaration
32+desugarDo :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Declaration -> m Declaration
33desugarDo (PositionedDeclaration pos com d) = PositionedDeclaration pos com <$> rethrowWithPosition pos (desugarDo d)
33desugarDo (PositionedDeclaration pos com d) = PositionedDeclaration pos com <$> rethrowWithPosition pos (desugarDo d)
34desugarDo d =
34desugarDo d =
35 let (f, _, _) = everywhereOnValuesM return replace return
35 let (f, _, _) = everywhereOnValuesM return replace return
src/Language/PureScript/Sugar/Names.hs+4−4
@@ -44,13 +44,13 @@ import Language.PureScript.Linter.Imports
44-- Replaces all local names with qualified names within a list of modules. The
44-- Replaces all local names with qualified names within a list of modules. The
45-- modules should be topologically sorted beforehand.
45-- modules should be topologically sorted beforehand.
46--
46--
47−desugarImports :: forall m. (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) => [ExternsFile] -> [Module] -> m [Module]
47+desugarImports :: forall m. (MonadError MultipleErrors m, MonadWriter MultipleErrors m) => [ExternsFile] -> [Module] -> m [Module]
48desugarImports externs modules =
48desugarImports externs modules =
49 fmap snd (desugarImportsWithEnv externs modules)
49 fmap snd (desugarImportsWithEnv externs modules)
50
50
51desugarImportsWithEnv
51desugarImportsWithEnv
52 :: forall m
52 :: forall m
53− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
53+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
54 => [ExternsFile]
54 => [ExternsFile]
55 -> [Module]
55 -> [Module]
56 -> m (Env, [Module])
56 -> m (Env, [Module])
@@ -141,7 +141,7 @@ elaborateExports exps (Module ss coms mn decls refs) =
141--
141--
142renameInModule
142renameInModule
143 :: forall m
143 :: forall m
144− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState UsedImports m)
144+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState UsedImports m)
145 => Env
145 => Env
146 -> Imports
146 -> Imports
147 -> Module
147 -> Module
@@ -334,7 +334,7 @@ renameInModule env imports (Module ss coms mn decls exps) =
334--
334--
335updateExportRefs
335updateExportRefs
336 :: forall m
336 :: forall m
337− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
337+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
338 => Module
338 => Module
339 -> m Module
339 -> m Module
340updateExportRefs (Module ss coms mn decls exps) =
340updateExportRefs (Module ss coms mn decls exps) =
src/Language/PureScript/Sugar/Names/Exports.hs+3−3
@@ -31,7 +31,7 @@ import Language.PureScript.Sugar.Names.Env
31-- |
31-- |
32-- Finds all exportable members of a module, disregarding any explicit exports.
32-- Finds all exportable members of a module, disregarding any explicit exports.
33--
33--
34−findExportable :: forall m. (Applicative m, MonadError MultipleErrors m) => Module -> m Exports
34+findExportable :: forall m. (MonadError MultipleErrors m) => Module -> m Exports
35findExportable (Module _ _ mn ds _) =
35findExportable (Module _ _ mn ds _) =
36 rethrow (addHint (ErrorInModule mn)) $ foldM updateExports nullExports ds
36 rethrow (addHint (ErrorInModule mn)) $ foldM updateExports nullExports ds
37 where
37 where
@@ -56,7 +56,7 @@ findExportable (Module _ _ mn ds _) =
56-- Resolves the exports for a module, filtering out members that have not been
56-- Resolves the exports for a module, filtering out members that have not been
57-- exported and elaborating re-exports of other modules.
57-- exported and elaborating re-exports of other modules.
58--
58--
59−resolveExports :: forall m. (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) => Env -> ModuleName -> Imports -> Exports -> [DeclarationRef] -> m Exports
59+resolveExports :: forall m. (MonadError MultipleErrors m, MonadWriter MultipleErrors m) => Env -> ModuleName -> Imports -> Exports -> [DeclarationRef] -> m Exports
60resolveExports env mn imps exps refs =
60resolveExports env mn imps exps refs =
61 rethrow (addHint (ErrorInModule mn)) $ do
61 rethrow (addHint (ErrorInModule mn)) $ do
62 filtered <- filterModule mn exps refs
62 filtered <- filterModule mn exps refs
@@ -199,7 +199,7 @@ resolveExports env mn imps exps refs =
199--
199--
200filterModule
200filterModule
201 :: forall m
201 :: forall m
202− . (Applicative m, MonadError MultipleErrors m)
202+ . (MonadError MultipleErrors m)
203 => ModuleName
203 => ModuleName
204 -> Exports
204 -> Exports
205 -> [DeclarationRef]
205 -> [DeclarationRef]
src/Language/PureScript/Sugar/Names/Imports.hs+4−4
@@ -37,7 +37,7 @@ import Language.PureScript.Sugar.Names.Env
37--
37--
38findImports
38findImports
39 :: forall m
39 :: forall m
40− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
40+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
41 => [Declaration]
41 => [Declaration]
42 -> m (M.Map ModuleName [(Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)])
42 -> m (M.Map ModuleName [(Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)])
43findImports = foldM (go Nothing) M.empty
43findImports = foldM (go Nothing) M.empty
@@ -56,7 +56,7 @@ type ImportDef = (Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)
56--
56--
57resolveImports
57resolveImports
58 :: forall m
58 :: forall m
59− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
59+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
60 => Env
60 => Env
61 -> Module
61 -> Module
62 -> m (Module, Imports)
62 -> m (Module, Imports)
@@ -160,7 +160,7 @@ resolveImports env (Module ss coms currentModule decls exps) =
160-- | Constructs a set of imports for a single module import.
160-- | Constructs a set of imports for a single module import.
161resolveModuleImport
161resolveModuleImport
162 :: forall m
162 :: forall m
163− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
163+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
164 => Env
164 => Env
165 -> Imports
165 -> Imports
166 -> (ModuleName, [(Maybe SourceSpan, Maybe ImportDeclarationType, Maybe ModuleName)])
166 -> (ModuleName, [(Maybe SourceSpan, Maybe ImportDeclarationType, Maybe ModuleName)])
@@ -187,7 +187,7 @@ resolveModuleImport env ie (mn, imps) = foldM go ie imps
187--
187--
188resolveImport
188resolveImport
189 :: forall m
189 :: forall m
190− . (Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
190+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
191 => ModuleName
191 => ModuleName
192 -> Exports
192 -> Exports
193 -> Imports
193 -> Imports
src/Language/PureScript/Sugar/ObjectWildcards.hs+1−1
@@ -21,7 +21,7 @@ import Language.PureScript.Names
21
21
22desugarObjectConstructors
22desugarObjectConstructors
23 :: forall m
23 :: forall m
24− . (Applicative m, MonadSupply m, MonadError MultipleErrors m)
24+ . (MonadSupply m, MonadError MultipleErrors m)
25 => Module
25 => Module
26 -> m Module
26 -> m Module
27desugarObjectConstructors (Module ss coms mn ds exts) = Module ss coms mn <$> mapM desugarDecl ds <*> pure exts
27desugarObjectConstructors (Module ss coms mn ds exts) = Module ss coms mn <$> mapM desugarDecl ds <*> pure exts
src/Language/PureScript/Sugar/Operators.hs+3−3
@@ -57,7 +57,7 @@ type AliasName = Either (Qualified Ident) (Qualified (ProperName 'ConstructorNam
57--
57--
58rebracket
58rebracket
59 :: forall m
59 :: forall m
60− . (Applicative m, MonadError MultipleErrors m)
60+ . (MonadError MultipleErrors m)
61 => [ExternsFile]
61 => [ExternsFile]
62 -> [Module]
62 -> [Module]
63 -> m [Module]
63 -> m [Module]
@@ -116,7 +116,7 @@ removeSignedLiterals (Module ss coms mn ds exts) = Module ss coms mn (map f' ds)
116 go other = other
116 go other = other
117
117
118rebracketModule
118rebracketModule
119− :: (Applicative m, MonadError MultipleErrors m)
119+ :: (MonadError MultipleErrors m)
120 => [[(Qualified Ident, Associativity)]]
120 => [[(Qualified Ident, Associativity)]]
121 -> Module
121 -> Module
122 -> m Module
122 -> m Module
@@ -178,7 +178,7 @@ customOperatorTable fixities =
178
178
179desugarOperatorSections
179desugarOperatorSections
180 :: forall m
180 :: forall m
181− . (Applicative m, MonadSupply m, MonadError MultipleErrors m)
181+ . (MonadSupply m, MonadError MultipleErrors m)
182 => Module
182 => Module
183 -> m Module
183 -> m Module
184desugarOperatorSections (Module ss coms mn ds exts) =
184desugarOperatorSections (Module ss coms mn ds exts) =
src/Language/PureScript/Sugar/TypeClasses.hs+4−4
@@ -45,7 +45,7 @@ type Desugar = StateT MemberMap
45-- instance dictionary expressions.
45-- instance dictionary expressions.
46--
46--
47desugarTypeClasses
47desugarTypeClasses
48− :: (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m)
48+ :: (MonadSupply m, MonadError MultipleErrors m)
49 => [ExternsFile]
49 => [ExternsFile]
50 -> [Module]
50 -> [Module]
51 -> m [Module]
51 -> m [Module]
@@ -62,7 +62,7 @@ desugarTypeClasses externs = flip evalStateT initialState . traverse desugarModu
62 fromExternsDecl _ _ = Nothing
62 fromExternsDecl _ _ = Nothing
63
63
64desugarModule
64desugarModule
65− :: (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m)
65+ :: (MonadSupply m, MonadError MultipleErrors m)
66 => Module
66 => Module
67 -> Desugar m Module
67 -> Desugar m Module
68desugarModule (Module ss coms name decls (Just exps)) = do
68desugarModule (Module ss coms name decls (Just exps)) = do
@@ -171,7 +171,7 @@ desugarModule _ = internalError "Exports should have been elaborated in name des
171-- };
171-- };
172-}
172-}
173desugarDecl
173desugarDecl
174− :: (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m)
174+ :: (MonadSupply m, MonadError MultipleErrors m)
175 => ModuleName
175 => ModuleName
176 -> [DeclarationRef]
176 -> [DeclarationRef]
177 -> Declaration
177 -> Declaration
@@ -259,7 +259,7 @@ unit = TypeApp tyObject REmpty
259
259
260typeInstanceDictionaryDeclaration
260typeInstanceDictionaryDeclaration
261 :: forall m
261 :: forall m
262− . (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m)
262+ . (MonadSupply m, MonadError MultipleErrors m)
263 => Ident
263 => Ident
264 -> ModuleName
264 -> ModuleName
265 -> [Constraint]
265 -> [Constraint]
src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+6−6
@@ -32,7 +32,7 @@ import qualified Language.PureScript.Constants as C
32
32
33-- | Elaborates deriving instance declarations by code generation.
33-- | Elaborates deriving instance declarations by code generation.
34deriveInstances
34deriveInstances
35− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadSupply m)
35+ :: (MonadError MultipleErrors m, MonadSupply m)
36 => Module
36 => Module
37 -> m Module
37 -> m Module
38deriveInstances (Module ss coms mn ds exts) = Module ss coms mn <$> mapM (deriveInstance mn ds) ds <*> pure exts
38deriveInstances (Module ss coms mn ds exts) = Module ss coms mn <$> mapM (deriveInstance mn ds) ds <*> pure exts
@@ -40,7 +40,7 @@ deriveInstances (Module ss coms mn ds exts) = Module ss coms mn <$> mapM (derive
40-- | Takes a declaration, and if the declaration is a deriving TypeInstanceDeclaration,
40-- | Takes a declaration, and if the declaration is a deriving TypeInstanceDeclaration,
41-- elaborates that into an instance declaration via code generation.
41-- elaborates that into an instance declaration via code generation.
42deriveInstance
42deriveInstance
43− :: (Functor m, MonadError MultipleErrors m, MonadSupply m)
43+ :: (MonadError MultipleErrors m, MonadSupply m)
44 => ModuleName
44 => ModuleName
45 -> [Declaration]
45 -> [Declaration]
46 -> Declaration
46 -> Declaration
@@ -82,7 +82,7 @@ typesProxy :: ModuleName
82typesProxy = ModuleName [ ProperName "Type", ProperName "Proxy" ]
82typesProxy = ModuleName [ ProperName "Type", ProperName "Proxy" ]
83
83
84deriveGeneric
84deriveGeneric
85− :: forall m. (Functor m, MonadError MultipleErrors m, MonadSupply m)
85+ :: forall m. (MonadError MultipleErrors m, MonadSupply m)
86 => ModuleName
86 => ModuleName
87 -> [Declaration]
87 -> [Declaration]
88 -> ProperName 'TypeName
88 -> ProperName 'TypeName
@@ -246,7 +246,7 @@ deriveGeneric mn ds tyConNm dargs = do
246 mkGenVar = mkVarMn (Just (ModuleName [ProperName "Data", ProperName C.generic]))
246 mkGenVar = mkVarMn (Just (ModuleName [ProperName "Data", ProperName C.generic]))
247
247
248deriveEq ::
248deriveEq ::
249− forall m. (Functor m, MonadError MultipleErrors m, MonadSupply m)
249+ forall m. (MonadError MultipleErrors m, MonadSupply m)
250 => ModuleName
250 => ModuleName
251 -> [Declaration]
251 -> [Declaration]
252 -> ProperName 'TypeName
252 -> ProperName 'TypeName
@@ -298,7 +298,7 @@ deriveEq mn ds tyConNm = do
298 toEqTest l r _ = preludeEq l r
298 toEqTest l r _ = preludeEq l r
299
299
300deriveOrd ::
300deriveOrd ::
301− forall m. (Functor m, MonadError MultipleErrors m, MonadSupply m)
301+ forall m. (MonadError MultipleErrors m, MonadSupply m)
302 => ModuleName
302 => ModuleName
303 -> [Declaration]
303 -> [Declaration]
304 -> ProperName 'TypeName
304 -> ProperName 'TypeName
@@ -377,7 +377,7 @@ deriveOrd mn ds tyConNm = do
377 toOrdering l r _ = preludeCompare l r
377 toOrdering l r _ = preludeCompare l r
378
378
379findTypeDecl
379findTypeDecl
380− :: (Functor m, MonadError MultipleErrors m)
380+ :: (MonadError MultipleErrors m)
381 => ProperName 'TypeName
381 => ProperName 'TypeName
382 -> [Declaration]
382 -> [Declaration]
383 -> m Declaration
383 -> m Declaration
src/Language/PureScript/Sugar/TypeDeclarations.hs+1−1
@@ -36,7 +36,7 @@ import Language.PureScript.Traversals
36-- |
36-- |
37-- Replace all top level type declarations in a module with type annotations
37-- Replace all top level type declarations in a module with type annotations
38--
38--
39−desugarTypeDeclarationsModule :: forall m. (Functor m, Applicative m, MonadError MultipleErrors m) => [Module] -> m [Module]
39+desugarTypeDeclarationsModule :: forall m. (MonadError MultipleErrors m) => [Module] -> m [Module]
40desugarTypeDeclarationsModule ms = forM ms $ \(Module ss coms name ds exps) ->
40desugarTypeDeclarationsModule ms = forM ms $ \(Module ss coms name ds exps) ->
41 rethrow (addHint (ErrorInModule name)) $
41 rethrow (addHint (ErrorInModule name)) $
42 Module ss coms name <$> desugarTypeDeclarations ds <*> pure exps
42 Module ss coms name <$> desugarTypeDeclarations ds <*> pure exps
src/Language/PureScript/TypeChecker.hs+12−12
@@ -40,7 +40,7 @@ import Language.PureScript.TypeClassDictionaries
40import Language.PureScript.Types
40import Language.PureScript.Types
41
41
42addDataType
42addDataType
43− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
43+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
44 => ModuleName
44 => ModuleName
45 -> DataDeclType
45 -> DataDeclType
46 -> ProperName 'TypeName
46 -> ProperName 'TypeName
@@ -56,7 +56,7 @@ addDataType moduleName dtype name args dctors ctorKind = do
56 addDataConstructor moduleName dtype name (map fst args) dctor tys
56 addDataConstructor moduleName dtype name (map fst args) dctor tys
57
57
58addDataConstructor
58addDataConstructor
59− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
59+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
60 => ModuleName
60 => ModuleName
61 -> DataDeclType
61 -> DataDeclType
62 -> ProperName 'TypeName
62 -> ProperName 'TypeName
@@ -74,7 +74,7 @@ addDataConstructor moduleName dtype name args dctor tys = do
74 putEnv $ env { dataConstructors = M.insert (Qualified (Just moduleName) dctor) (dtype, name, polyType, fields) (dataConstructors env) }
74 putEnv $ env { dataConstructors = M.insert (Qualified (Just moduleName) dctor) (dtype, name, polyType, fields) (dataConstructors env) }
75
75
76addTypeSynonym
76addTypeSynonym
77− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
77+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
78 => ModuleName
78 => ModuleName
79 -> ProperName 'TypeName
79 -> ProperName 'TypeName
80 -> [(String, Maybe Kind)]
80 -> [(String, Maybe Kind)]
@@ -88,7 +88,7 @@ addTypeSynonym moduleName name args ty kind = do
88 , typeSynonyms = M.insert (Qualified (Just moduleName) name) (args, ty) (typeSynonyms env) }
88 , typeSynonyms = M.insert (Qualified (Just moduleName) name) (args, ty) (typeSynonyms env) }
89
89
90valueIsNotDefined
90valueIsNotDefined
91− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
91+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
92 => ModuleName
92 => ModuleName
93 -> Ident
93 -> Ident
94 -> m ()
94 -> m ()
@@ -99,7 +99,7 @@ valueIsNotDefined moduleName name = do
99 Nothing -> return ()
99 Nothing -> return ()
100
100
101addValue
101addValue
102− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
102+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
103 => ModuleName
103 => ModuleName
104 -> Ident
104 -> Ident
105 -> Type
105 -> Type
@@ -110,7 +110,7 @@ addValue moduleName name ty nameKind = do
110 putEnv (env { names = M.insert (moduleName, name) (ty, nameKind, Defined) (names env) })
110 putEnv (env { names = M.insert (moduleName, name) (ty, nameKind, Defined) (names env) })
111
111
112addTypeClass
112addTypeClass
113− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
113+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
114 => ModuleName
114 => ModuleName
115 -> ProperName 'ClassName
115 -> ProperName 'ClassName
116 -> [(String, Maybe Kind)]
116 -> [(String, Maybe Kind)]
@@ -126,7 +126,7 @@ addTypeClass moduleName pn args implies ds =
126 toPair _ = internalError "Invalid declaration in TypeClassDeclaration"
126 toPair _ = internalError "Invalid declaration in TypeClassDeclaration"
127
127
128addTypeClassDictionaries
128addTypeClassDictionaries
129− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
129+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
130 => Maybe ModuleName
130 => Maybe ModuleName
131 -> M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)
131 -> M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)
132 -> m ()
132 -> m ()
@@ -135,7 +135,7 @@ addTypeClassDictionaries mn entries =
135 where insertState st = M.insertWith (M.unionWith M.union) mn entries (typeClassDictionaries . checkEnv $ st)
135 where insertState st = M.insertWith (M.unionWith M.union) mn entries (typeClassDictionaries . checkEnv $ st)
136
136
137checkDuplicateTypeArguments
137checkDuplicateTypeArguments
138− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
138+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
139 => [String]
139 => [String]
140 -> m ()
140 -> m ()
141checkDuplicateTypeArguments args = for_ firstDup $ \dup ->
141checkDuplicateTypeArguments args = for_ firstDup $ \dup ->
@@ -145,7 +145,7 @@ checkDuplicateTypeArguments args = for_ firstDup $ \dup ->
145 firstDup = listToMaybe $ args \\ nub args
145 firstDup = listToMaybe $ args \\ nub args
146
146
147checkTypeClassInstance
147checkTypeClassInstance
148− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
148+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
149 => ModuleName
149 => ModuleName
150 -> Type
150 -> Type
151 -> m ()
151 -> m ()
@@ -161,7 +161,7 @@ checkTypeClassInstance _ ty = throwError . errorMessage $ InvalidInstanceHead ty
161-- Check that type synonyms are fully-applied in a type
161-- Check that type synonyms are fully-applied in a type
162--
162--
163checkTypeSynonyms
163checkTypeSynonyms
164− :: (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
164+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
165 => Type
165 => Type
166 -> m ()
166 -> m ()
167checkTypeSynonyms = void . replaceAllTypeSynonyms
167checkTypeSynonyms = void . replaceAllTypeSynonyms
@@ -181,7 +181,7 @@ checkTypeSynonyms = void . replaceAllTypeSynonyms
181--
181--
182typeCheckAll
182typeCheckAll
183 :: forall m
183 :: forall m
184− . (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
184+ . (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
185 => ModuleName
185 => ModuleName
186 -> [DeclarationRef]
186 -> [DeclarationRef]
187 -> [Declaration]
187 -> [Declaration]
@@ -343,7 +343,7 @@ typeCheckAll moduleName _ ds = traverse go ds <* traverse_ checkFixities ds
343--
343--
344typeCheckModule
344typeCheckModule
345 :: forall m
345 :: forall m
346− . (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
346+ . (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
347 => Module
347 => Module
348 -> m Module
348 -> m Module
349typeCheckModule (Module _ _ _ _ Nothing) = internalError "exports should have been elaborated"
349typeCheckModule (Module _ _ _ _ Nothing) = internalError "exports should have been elaborated"
src/Language/PureScript/TypeChecker/Entailment.hs+2−2
@@ -41,7 +41,7 @@ combineContexts = M.unionWith (M.unionWith M.union)
41
41
42-- | Replace type class dictionary placeholders with inferred type class dictionaries
42-- | Replace type class dictionary placeholders with inferred type class dictionaries
43replaceTypeClassDictionaries
43replaceTypeClassDictionaries
44− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m)
44+ :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m)
45 => Bool
45 => Bool
46 -> ModuleName
46 -> ModuleName
47 -> Expr
47 -> Expr
@@ -59,7 +59,7 @@ replaceTypeClassDictionaries shouldGeneralize mn =
59--
59--
60entails
60entails
61 :: forall m
61 :: forall m
62− . (Functor m, Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m)
62+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m)
63 => Bool
63 => Bool
64 -> ModuleName
64 -> ModuleName
65 -> Context
65 -> Context
src/Language/PureScript/TypeChecker/Kinds.hs+11−11
@@ -43,7 +43,7 @@ freshKind = do
43
43
44-- | Update the substitution to solve a kind constraint
44-- | Update the substitution to solve a kind constraint
45solveKind
45solveKind
46− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m)
46+ :: (MonadError MultipleErrors m, MonadState CheckState m)
47 => Int
47 => Int
48 -> Kind
48 -> Kind
49 -> m ()
49 -> m ()
@@ -68,7 +68,7 @@ substituteKind sub = everywhereOnKinds go
68
68
69-- | Make sure that an unknown does not occur in a kind
69-- | Make sure that an unknown does not occur in a kind
70occursCheck
70occursCheck
71− :: (Functor m, Applicative m, MonadError MultipleErrors m)
71+ :: (MonadError MultipleErrors m)
72 => Int
72 => Int
73 -> Kind
73 -> Kind
74 -> m ()
74 -> m ()
@@ -80,7 +80,7 @@ occursCheck u k = void $ everywhereOnKindsM go k
80
80
81-- | Unify two kinds
81-- | Unify two kinds
82unifyKinds
82unifyKinds
83− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m)
83+ :: (MonadError MultipleErrors m, MonadState CheckState m)
84 => Kind
84 => Kind
85 -> Kind
85 -> Kind
86 -> m ()
86 -> m ()
@@ -101,14 +101,14 @@ unifyKinds k1 k2 = do
101
101
102-- | Infer the kind of a single type
102-- | Infer the kind of a single type
103kindOf
103kindOf
104− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m)
104+ :: (MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m)
105 => Type
105 => Type
106 -> m Kind
106 -> m Kind
107kindOf ty = fst <$> kindOfWithScopedVars ty
107kindOf ty = fst <$> kindOfWithScopedVars ty
108
108
109-- | Infer the kind of a single type, returning the kinds of any scoped type variables
109-- | Infer the kind of a single type, returning the kinds of any scoped type variables
110kindOfWithScopedVars ::
110kindOfWithScopedVars ::
111− (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m) =>
111+ (MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m) =>
112 Type ->
112 Type ->
113 m (Kind, [(String, Kind)])
113 m (Kind, [(String, Kind)])
114kindOfWithScopedVars ty =
114kindOfWithScopedVars ty =
@@ -121,7 +121,7 @@ kindOfWithScopedVars ty =
121
121
122-- | Infer the kind of a type constructor with a collection of arguments and a collection of associated data constructors
122-- | Infer the kind of a type constructor with a collection of arguments and a collection of associated data constructors
123kindsOf
123kindsOf
124− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m)
124+ :: (MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m)
125 => Bool
125 => Bool
126 -> ModuleName
126 -> ModuleName
127 -> ProperName 'TypeName
127 -> ProperName 'TypeName
@@ -139,7 +139,7 @@ kindsOf isData moduleName name args ts = fmap tidyUp . liftUnify $ do
139 tidyUp (k, sub) = starIfUnknown $ substituteKind sub k
139 tidyUp (k, sub) = starIfUnknown $ substituteKind sub k
140
140
141freshKindVar
141freshKindVar
142− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m)
142+ :: (MonadError MultipleErrors m, MonadState CheckState m)
143 => (String, Maybe Kind)
143 => (String, Maybe Kind)
144 -> Kind
144 -> Kind
145 -> m (ProperName 'TypeName, Kind)
145 -> m (ProperName 'TypeName, Kind)
@@ -150,7 +150,7 @@ freshKindVar (arg, Just kind') kind = do
150
150
151-- | Simultaneously infer the kinds of several mutually recursive type constructors
151-- | Simultaneously infer the kinds of several mutually recursive type constructors
152kindsOfAll
152kindsOfAll
153− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m)
153+ :: (MonadError MultipleErrors m, MonadState CheckState m, MonadWriter MultipleErrors m)
154 => ModuleName
154 => ModuleName
155 -> [(ProperName 'TypeName, [(String, Maybe Kind)], Type)]
155 -> [(ProperName 'TypeName, [(String, Maybe Kind)], Type)]
156 -> [(ProperName 'TypeName, [(String, Maybe Kind)], [Type])]
156 -> [(ProperName 'TypeName, [(String, Maybe Kind)], [Type])]
@@ -178,7 +178,7 @@ kindsOfAll moduleName syns tys = fmap tidyUp . liftUnify $ do
178
178
179-- | Solve the set of kind constraints associated with the data constructors for a type constructor
179-- | Solve the set of kind constraints associated with the data constructors for a type constructor
180solveTypes
180solveTypes
181− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m)
181+ :: (MonadError MultipleErrors m, MonadState CheckState m)
182 => Bool
182 => Bool
183 -> [Type]
183 -> [Type]
184 -> [Kind]
184 -> [Kind]
@@ -202,14 +202,14 @@ starIfUnknown k = k
202
202
203-- | Infer a kind for a type
203-- | Infer a kind for a type
204infer
204infer
205− :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m)
205+ :: (MonadError MultipleErrors m, MonadState CheckState m)
206 => Type
206 => Type
207 -> m (Kind, [(String, Kind)])
207 -> m (Kind, [(String, Kind)])
208infer ty = rethrow (addHint (ErrorCheckingKind ty)) $ infer' ty
208infer ty = rethrow (addHint (ErrorCheckingKind ty)) $ infer' ty
209
209
210infer'
210infer'
211 :: forall m
211 :: forall m
212− . (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m)
212+ . (MonadError MultipleErrors m, MonadState CheckState m)
213 => Type
213 => Type
214 -> m (Kind, [(String, Kind)])
214 -> m (Kind, [(String, Kind)])
215infer' (ForAll ident ty _) = do
215infer' (ForAll ident ty _) = do
src/Language/PureScript/TypeChecker/Monad.hs+15−15
@@ -84,7 +84,7 @@ bindTypes newNames action = do
84
84
85-- | Temporarily bind a collection of names to types
85-- | Temporarily bind a collection of names to types
86withScopedTypeVars
86withScopedTypeVars
87− :: (Functor m, Applicative m, MonadState CheckState m, MonadWriter MultipleErrors m)
87+ :: (MonadState CheckState m, MonadWriter MultipleErrors m)
88 => ModuleName
88 => ModuleName
89 -> [(String, Kind)]
89 -> [(String, Kind)]
90 -> m a
90 -> m a
@@ -112,20 +112,20 @@ withTypeClassDictionaries entries action = do
112
112
113-- | Get the currently available map of type class dictionaries
113-- | Get the currently available map of type class dictionaries
114getTypeClassDictionaries
114getTypeClassDictionaries
115− :: (Functor m, MonadState CheckState m)
115+ :: (MonadState CheckState m)
116 => m (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)))
116 => m (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)))
117getTypeClassDictionaries = typeClassDictionaries . checkEnv <$> get
117getTypeClassDictionaries = typeClassDictionaries . checkEnv <$> get
118
118
119-- | Lookup type class dictionaries in a module.
119-- | Lookup type class dictionaries in a module.
120lookupTypeClassDictionaries
120lookupTypeClassDictionaries
121− :: (Functor m, MonadState CheckState m)
121+ :: (MonadState CheckState m)
122 => Maybe ModuleName
122 => Maybe ModuleName
123 -> m (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope))
123 -> m (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope))
124lookupTypeClassDictionaries mn = fromMaybe M.empty . M.lookup mn . typeClassDictionaries . checkEnv <$> get
124lookupTypeClassDictionaries mn = fromMaybe M.empty . M.lookup mn . typeClassDictionaries . checkEnv <$> get
125
125
126-- | Temporarily bind a collection of names to local variables
126-- | Temporarily bind a collection of names to local variables
127bindLocalVariables
127bindLocalVariables
128− :: (Functor m, MonadState CheckState m)
128+ :: (MonadState CheckState m)
129 => ModuleName
129 => ModuleName
130 -> [(Ident, Type, NameVisibility)]
130 -> [(Ident, Type, NameVisibility)]
131 -> m a
131 -> m a
@@ -135,7 +135,7 @@ bindLocalVariables moduleName bindings =
135
135
136-- | Temporarily bind a collection of names to local type variables
136-- | Temporarily bind a collection of names to local type variables
137bindLocalTypeVariables
137bindLocalTypeVariables
138− :: (Functor m, MonadState CheckState m)
138+ :: (MonadState CheckState m)
139 => ModuleName
139 => ModuleName
140 -> [(ProperName 'TypeName, Kind)]
140 -> [(ProperName 'TypeName, Kind)]
141 -> m a
141 -> m a
@@ -144,15 +144,15 @@ bindLocalTypeVariables moduleName bindings =
144 bindTypes (M.fromList $ flip map bindings $ \(pn, kind) -> (Qualified (Just moduleName) pn, (kind, LocalTypeVariable)))
144 bindTypes (M.fromList $ flip map bindings $ \(pn, kind) -> (Qualified (Just moduleName) pn, (kind, LocalTypeVariable)))
145
145
146-- | Update the visibility of all names to Defined
146-- | Update the visibility of all names to Defined
147−makeBindingGroupVisible :: (Functor m, MonadState CheckState m) => m ()
147+makeBindingGroupVisible :: (MonadState CheckState m) => m ()
148makeBindingGroupVisible = modifyEnv $ \e -> e { names = M.map (\(ty, nk, _) -> (ty, nk, Defined)) (names e) }
148makeBindingGroupVisible = modifyEnv $ \e -> e { names = M.map (\(ty, nk, _) -> (ty, nk, Defined)) (names e) }
149
149
150-- | Update the visibility of all names to Defined in the scope of the provided action
150-- | Update the visibility of all names to Defined in the scope of the provided action
151−withBindingGroupVisible :: (Functor m, MonadState CheckState m) => m a -> m a
151+withBindingGroupVisible :: (MonadState CheckState m) => m a -> m a
152withBindingGroupVisible action = preservingNames $ makeBindingGroupVisible >> action
152withBindingGroupVisible action = preservingNames $ makeBindingGroupVisible >> action
153
153
154-- | Perform an action while preserving the names from the @Environment@.
154-- | Perform an action while preserving the names from the @Environment@.
155−preservingNames :: (Functor m, MonadState CheckState m) => m a -> m a
155+preservingNames :: (MonadState CheckState m) => m a -> m a
156preservingNames action = do
156preservingNames action = do
157 orig <- gets (names . checkEnv)
157 orig <- gets (names . checkEnv)
158 a <- action
158 a <- action
@@ -161,7 +161,7 @@ preservingNames action = do
161
161
162-- | Lookup the type of a value by name in the @Environment@
162-- | Lookup the type of a value by name in the @Environment@
163lookupVariable
163lookupVariable
164− :: (e ~ MultipleErrors, Functor m, MonadState CheckState m, MonadError e m)
164+ :: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m)
165 => ModuleName
165 => ModuleName
166 -> Qualified Ident
166 -> Qualified Ident
167 -> m Type
167 -> m Type
@@ -173,7 +173,7 @@ lookupVariable currentModule (Qualified moduleName var) = do
173
173
174-- | Lookup the visibility of a value by name in the @Environment@
174-- | Lookup the visibility of a value by name in the @Environment@
175getVisibility
175getVisibility
176− :: (e ~ MultipleErrors, Functor m, MonadState CheckState m, MonadError e m)
176+ :: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m)
177 => ModuleName
177 => ModuleName
178 -> Qualified Ident
178 -> Qualified Ident
179 -> m NameVisibility
179 -> m NameVisibility
@@ -185,7 +185,7 @@ getVisibility currentModule (Qualified moduleName var) = do
185
185
186-- | Assert that a name is visible
186-- | Assert that a name is visible
187checkVisibility
187checkVisibility
188− :: (e ~ MultipleErrors, Functor m, MonadState CheckState m, MonadError e m)
188+ :: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m)
189 => ModuleName
189 => ModuleName
190 -> Qualified Ident
190 -> Qualified Ident
191 -> m ()
191 -> m ()
@@ -197,7 +197,7 @@ checkVisibility currentModule name@(Qualified _ var) = do
197
197
198-- | Lookup the kind of a type by name in the @Environment@
198-- | Lookup the kind of a type by name in the @Environment@
199lookupTypeVariable
199lookupTypeVariable
200− :: (e ~ MultipleErrors, Functor m, MonadState CheckState m, MonadError e m)
200+ :: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m)
201 => ModuleName
201 => ModuleName
202 -> Qualified (ProperName 'TypeName)
202 -> Qualified (ProperName 'TypeName)
203 -> m Kind
203 -> m Kind
@@ -208,7 +208,7 @@ lookupTypeVariable currentModule (Qualified moduleName name) = do
208 Just (k, _) -> return k
208 Just (k, _) -> return k
209
209
210-- | Get the current @Environment@
210-- | Get the current @Environment@
211−getEnv :: (Functor m, MonadState CheckState m) => m Environment
211+getEnv :: (MonadState CheckState m) => m Environment
212getEnv = checkEnv <$> get
212getEnv = checkEnv <$> get
213
213
214-- | Update the @Environment@
214-- | Update the @Environment@
@@ -234,14 +234,14 @@ guardWith e False = throwError e
234
234
235-- | Run a computation in the substitution monad, generating a return value and the final substitution.
235-- | Run a computation in the substitution monad, generating a return value and the final substitution.
236liftUnify ::
236liftUnify ::
237− (Functor m, MonadState CheckState m, MonadWriter MultipleErrors m, MonadError MultipleErrors m) =>
237+ (MonadState CheckState m, MonadWriter MultipleErrors m, MonadError MultipleErrors m) =>
238 m a ->
238 m a ->
239 m (a, Substitution)
239 m (a, Substitution)
240liftUnify = liftUnifyWarnings (const id)
240liftUnify = liftUnifyWarnings (const id)
241
241
242-- | Run a computation in the substitution monad, generating a return value, the final substitution and updating warnings values.
242-- | Run a computation in the substitution monad, generating a return value, the final substitution and updating warnings values.
243liftUnifyWarnings ::
243liftUnifyWarnings ::
244− (Functor m, MonadState CheckState m, MonadWriter MultipleErrors m, MonadError MultipleErrors m) =>
244+ (MonadState CheckState m, MonadWriter MultipleErrors m, MonadError MultipleErrors m) =>
245 (Substitution -> ErrorMessage -> ErrorMessage) ->
245 (Substitution -> ErrorMessage -> ErrorMessage) ->
246 m a ->
246 m a ->
247 m (a, Substitution)
247 m (a, Substitution)
src/Language/PureScript/TypeChecker/Rows.hs+1−1
@@ -36,7 +36,7 @@ import Language.PureScript.TypeChecker.Monad
36import Language.PureScript.Types
36import Language.PureScript.Types
37
37
38-- | Ensure rows do not contain duplicate labels
38-- | Ensure rows do not contain duplicate labels
39−checkDuplicateLabels :: forall m. (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Expr -> m ()
39+checkDuplicateLabels :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => Expr -> m ()
40checkDuplicateLabels =
40checkDuplicateLabels =
41 let (_, f, _) = everywhereOnValuesM def go def
41 let (_, f, _) = everywhereOnValuesM def go def
42 in void . f
42 in void . f
src/Language/PureScript/TypeChecker/Skolems.hs+1−1
@@ -53,7 +53,7 @@ newSkolemConstant = do
53-- |
53-- |
54-- Introduce skolem scope at every occurence of a ForAll
54-- Introduce skolem scope at every occurence of a ForAll
55--
55--
56−introduceSkolemScope :: (Functor m, Applicative m, MonadState CheckState m) => Type -> m Type
56+introduceSkolemScope :: (MonadState CheckState m) => Type -> m Type
57introduceSkolemScope = everywhereOnTypesM go
57introduceSkolemScope = everywhereOnTypesM go
58 where
58 where
59 go (ForAll ident ty Nothing) = ForAll ident ty <$> (Just <$> newSkolemScope)
59 go (ForAll ident ty Nothing) = ForAll ident ty <$> (Just <$> newSkolemScope)
src/Language/PureScript/TypeChecker/Subsumption.hs+2−2
@@ -39,11 +39,11 @@ import Language.PureScript.TypeChecker.Unify
39import Language.PureScript.Types
39import Language.PureScript.Types
40
40
41-- | Check that one type subsumes another, rethrowing errors to provide a better error message
41-- | Check that one type subsumes another, rethrowing errors to provide a better error message
42−subsumes :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Maybe Expr -> Type -> Type -> m (Maybe Expr)
42+subsumes :: (MonadError MultipleErrors m, MonadState CheckState m) => Maybe Expr -> Type -> Type -> m (Maybe Expr)
43subsumes val ty1 ty2 = rethrow (addHint (ErrorInSubsumption ty1 ty2)) $ subsumes' val ty1 ty2
43subsumes val ty1 ty2 = rethrow (addHint (ErrorInSubsumption ty1 ty2)) $ subsumes' val ty1 ty2
44
44
45-- | Check tahat one type subsumes another
45-- | Check tahat one type subsumes another
46−subsumes' :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) =>
46+subsumes' :: (MonadError MultipleErrors m, MonadState CheckState m) =>
47 Maybe Expr ->
47 Maybe Expr ->
48 Type ->
48 Type ->
49 Type ->
49 Type ->
src/Language/PureScript/TypeChecker/Synonyms.hs+1−1
@@ -57,7 +57,7 @@ replaceAllTypeSynonyms' env = everywhereOnTypesTopDownM try
57 go c args (TypeApp f arg) = go (c + 1) (arg : args) f
57 go c args (TypeApp f arg) = go (c + 1) (arg : args) f
58 go _ _ _ = return Nothing
58 go _ _ _ = return Nothing
59
59
60−replaceAllTypeSynonyms :: (e ~ MultipleErrors, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
60+replaceAllTypeSynonyms :: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m) => Type -> m Type
61replaceAllTypeSynonyms d = do
61replaceAllTypeSynonyms d = do
62 env <- getEnv
62 env <- getEnv
63 either throwError return $ replaceAllTypeSynonyms' env d
63 either throwError return $ replaceAllTypeSynonyms' env d
src/Language/PureScript/TypeChecker/Types.hs+19−19
@@ -62,7 +62,7 @@ import Language.PureScript.Types
62-- | Infer the types of multiple mutually-recursive values, and return elaborated values including
62-- | Infer the types of multiple mutually-recursive values, and return elaborated values including
63-- type class dictionaries and type annotations.
63-- type class dictionaries and type annotations.
64typesOf ::
64typesOf ::
65− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
65+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
66 ModuleName ->
66 ModuleName ->
67 [(Ident, Expr)] ->
67 [(Ident, Expr)] ->
68 m [(Ident, (Expr, Type))]
68 m [(Ident, (Expr, Type))]
@@ -109,7 +109,7 @@ type TypeData = M.Map (ModuleName, Ident) (Type, NameKind, NameVisibility)
109type UntypedData = [(Ident, Type)]
109type UntypedData = [(Ident, Type)]
110
110
111typeDictionaryForBindingGroup ::
111typeDictionaryForBindingGroup ::
112− (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
112+ (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
113 ModuleName ->
113 ModuleName ->
114 [(Ident, Expr)] ->
114 [(Ident, Expr)] ->
115 m ([(Ident, Expr)], [(Ident, (Expr, Type, Bool))], TypeData, UntypedData)
115 m ([(Ident, Expr)], [(Ident, (Expr, Type, Bool))], TypeData, UntypedData)
@@ -134,7 +134,7 @@ typeDictionaryForBindingGroup moduleName vals = do
134 return (untyped, typed, dict, untypedDict)
134 return (untyped, typed, dict, untypedDict)
135
135
136checkTypedBindingGroupElement ::
136checkTypedBindingGroupElement ::
137− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
137+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
138 ModuleName ->
138 ModuleName ->
139 (Ident, (Expr, Type, Bool)) ->
139 (Ident, (Expr, Type, Bool)) ->
140 TypeData ->
140 TypeData ->
@@ -153,7 +153,7 @@ checkTypedBindingGroupElement mn (ident, (val', ty, checkType)) dict = do
153 return (ident, (val'', ty''))
153 return (ident, (val'', ty''))
154
154
155typeForBindingGroupElement ::
155typeForBindingGroupElement ::
156− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
156+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
157 (Ident, Expr) ->
157 (Ident, Expr) ->
158 TypeData ->
158 TypeData ->
159 UntypedData ->
159 UntypedData ->
@@ -179,10 +179,10 @@ 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− (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m) =>
185+ (MonadState CheckState m, MonadError MultipleErrors m) =>
186 Type ->
186 Type ->
187 Kind ->
187 Kind ->
188 m ()
188 m ()
@@ -194,7 +194,7 @@ checkTypeKind ty kind = guardWith (errorMessage (ExpectedType ty kind)) $ kind =
194-- This is necessary during type checking to avoid unifying a polymorphic type with a
194-- This is necessary during type checking to avoid unifying a polymorphic type with a
195-- unification variable.
195-- unification variable.
196instantiatePolyTypeWithUnknowns ::
196instantiatePolyTypeWithUnknowns ::
197− (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m) =>
197+ (MonadState CheckState m, MonadError MultipleErrors m) =>
198 Expr ->
198 Expr ->
199 Type ->
199 Type ->
200 m (Expr, Type)
200 m (Expr, Type)
@@ -208,14 +208,14 @@ instantiatePolyTypeWithUnknowns val ty = return (val, ty)
208
208
209-- | Infer a type for a value, rethrowing any error to provide a more useful error message
209-- | Infer a type for a value, rethrowing any error to provide a more useful error message
210infer ::
210infer ::
211− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
211+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
212 Expr ->
212 Expr ->
213 m Expr
213 m Expr
214infer val = rethrow (addHint (ErrorInferringType val)) $ infer' val
214infer val = rethrow (addHint (ErrorInferringType val)) $ infer' val
215
215
216-- | Infer a type for a value
216-- | Infer a type for a value
217infer' ::
217infer' ::
218− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
218+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
219 Expr ->
219 Expr ->
220 m Expr
220 m Expr
221infer' v@(Literal (NumericLiteral (Left _))) = return $ TypedValue True v tyInt
221infer' v@(Literal (NumericLiteral (Left _))) = return $ TypedValue True v tyInt
@@ -304,7 +304,7 @@ infer' (PositionedValue pos c val) = warnAndRethrowWithPosition pos $ do
304infer' _ = internalError "Invalid argument to infer"
304infer' _ = internalError "Invalid argument to infer"
305
305
306inferLetBinding ::
306inferLetBinding ::
307− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
307+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
308 [Declaration] ->
308 [Declaration] ->
309 [Declaration] ->
309 [Declaration] ->
310 Expr ->
310 Expr ->
@@ -342,7 +342,7 @@ inferLetBinding _ _ _ _ = internalError "Invalid argument to inferLetBinding"
342
342
343-- | Infer the types of variables brought into scope by a binder
343-- | Infer the types of variables brought into scope by a binder
344inferBinder :: forall m.
344inferBinder :: forall m.
345− (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
345+ (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
346 Type ->
346 Type ->
347 Binder ->
347 Binder ->
348 m (M.Map Ident Type)
348 m (M.Map Ident Type)
@@ -421,7 +421,7 @@ binderRequiresMonotype _ = True
421
421
422-- | Instantiate polytypes only when necessitated by a binder.
422-- | Instantiate polytypes only when necessitated by a binder.
423instantiateForBinders ::
423instantiateForBinders ::
424− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
424+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
425 [Expr] ->
425 [Expr] ->
426 [CaseAlternative] ->
426 [CaseAlternative] ->
427 m ([Expr], [Type])
427 m ([Expr], [Type])
@@ -438,7 +438,7 @@ instantiateForBinders vals cas = unzip <$> zipWithM (\val inst -> do
438-- Check the types of the return values in a set of binders in a case statement
438-- Check the types of the return values in a set of binders in a case statement
439--
439--
440checkBinders ::
440checkBinders ::
441− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
441+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
442 [Type] ->
442 [Type] ->
443 Type ->
443 Type ->
444 [CaseAlternative] ->
444 [CaseAlternative] ->
@@ -468,7 +468,7 @@ checkBinders nvals ret (CaseAlternative binders result : bs) = do
468-- Check the type of a value, rethrowing errors to provide a better error message
468-- Check the type of a value, rethrowing errors to provide a better error message
469--
469--
470check ::
470check ::
471− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
471+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
472 Expr ->
472 Expr ->
473 Type ->
473 Type ->
474 m Expr
474 m Expr
@@ -479,7 +479,7 @@ check val ty = rethrow (addHint (ErrorCheckingType val ty)) $ check' val ty
479--
479--
480check'
480check'
481 :: forall m
481 :: forall m
482− . (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
482+ . (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
483 => Expr
483 => Expr
484 -> Type
484 -> Type
485 -> m Expr
485 -> m Expr
@@ -642,7 +642,7 @@ check' val ty = do
642-- The @lax@ parameter controls whether or not every record member has to be provided. For object updates, this is not the case.
642-- The @lax@ parameter controls whether or not every record member has to be provided. For object updates, this is not the case.
643--
643--
644checkProperties ::
644checkProperties ::
645− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
645+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
646 Expr ->
646 Expr ->
647 [(String, Expr)] ->
647 [(String, Expr)] ->
648 Type ->
648 Type ->
@@ -674,7 +674,7 @@ checkProperties expr ps row lax = let (ts, r') = rowToList row in go ps ts r' wh
674
674
675-- | Check the type of a function application, rethrowing errors to provide a better error message
675-- | Check the type of a function application, rethrowing errors to provide a better error message
676checkFunctionApplication ::
676checkFunctionApplication ::
677− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
677+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
678 Expr ->
678 Expr ->
679 Type ->
679 Type ->
680 Expr ->
680 Expr ->
@@ -686,7 +686,7 @@ checkFunctionApplication fn fnTy arg ret = rethrow (addHint (ErrorInApplication
686
686
687-- | Check the type of a function application
687-- | Check the type of a function application
688checkFunctionApplication' ::
688checkFunctionApplication' ::
689− (Functor m, Applicative m, MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
689+ (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) =>
690 Expr ->
690 Expr ->
691 Type ->
691 Type ->
692 Expr ->
692 Expr ->
@@ -724,7 +724,7 @@ checkFunctionApplication' _ fnTy arg _ = throwError . errorMessage $ CannotApply
724-- | Compute the meet of two types, i.e. the most general type which both types subsume.
724-- | Compute the meet of two types, i.e. the most general type which both types subsume.
725-- TODO: is this really needed?
725-- TODO: is this really needed?
726meet ::
726meet ::
727− (Functor m, Applicative m, MonadState CheckState m, MonadError MultipleErrors m) =>
727+ (MonadState CheckState m, MonadError MultipleErrors m) =>
728 Expr ->
728 Expr ->
729 Expr ->
729 Expr ->
730 Type ->
730 Type ->
src/Language/PureScript/TypeChecker/Unify.hs+5−5
@@ -57,7 +57,7 @@ freshType = do
57 return $ TUnknown t
57 return $ TUnknown t
58
58
59-- | Update the substitution to solve a type constraint
59-- | Update the substitution to solve a type constraint
60−solveType :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Int -> Type -> m ()
60+solveType :: (MonadError MultipleErrors m, MonadState CheckState m) => Int -> Type -> m ()
61solveType u t = do
61solveType u t = do
62 occursCheck u t
62 occursCheck u t
63 modify $ \cs -> cs { checkSubstitution =
63 modify $ \cs -> cs { checkSubstitution =
@@ -78,7 +78,7 @@ substituteType sub = everywhereOnTypes go
78 go other = other
78 go other = other
79
79
80-- | Make sure that an unknown does not occur in a type
80-- | Make sure that an unknown does not occur in a type
81−occursCheck :: (Functor m, Applicative m, MonadError MultipleErrors m) => Int -> Type -> m ()
81+occursCheck :: (MonadError MultipleErrors m) => Int -> Type -> m ()
82occursCheck _ TUnknown{} = return ()
82occursCheck _ TUnknown{} = return ()
83occursCheck u t = void $ everywhereOnTypesM go t
83occursCheck u t = void $ everywhereOnTypesM go t
84 where
84 where
@@ -94,7 +94,7 @@ unknownsInType t = everythingOnTypes (.) go t []
94 go _ = id
94 go _ = id
95
95
96-- | Unify two types, updating the current substitution
96-- | Unify two types, updating the current substitution
97−unifyTypes :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m ()
97+unifyTypes :: (MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m ()
98unifyTypes t1 t2 = do
98unifyTypes t1 t2 = do
99 sub <- gets checkSubstitution
99 sub <- gets checkSubstitution
100 rethrow (addHint (ErrorUnifyingTypes t1 t2)) $ unifyTypes' (substituteType sub t1) (substituteType sub t2)
100 rethrow (addHint (ErrorUnifyingTypes t1 t2)) $ unifyTypes' (substituteType sub t1) (substituteType sub t2)
@@ -140,7 +140,7 @@ unifyTypes t1 t2 = do
140-- trailing row unification variable, if appropriate, otherwise leftover labels result in a unification
140-- trailing row unification variable, if appropriate, otherwise leftover labels result in a unification
141-- error.
141-- error.
142--
142--
143−unifyRows :: forall m. (Functor m, Applicative m, MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m ()
143+unifyRows :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => Type -> Type -> m ()
144unifyRows r1 r2 =
144unifyRows r1 r2 =
145 let
145 let
146 (s1, r1') = rowToList r1
146 (s1, r1') = rowToList r1
@@ -206,7 +206,7 @@ replaceVarWithUnknown ident ty = do
206-- |
206-- |
207-- Replace type wildcards with unknowns
207-- Replace type wildcards with unknowns
208--
208--
209−replaceTypeWildcards :: (Functor m, Applicative m, MonadWriter MultipleErrors m, MonadState CheckState m) => Type -> m Type
209+replaceTypeWildcards :: (MonadWriter MultipleErrors m, MonadState CheckState m) => Type -> m Type
210replaceTypeWildcards = everywhereOnTypesM replace
210replaceTypeWildcards = everywhereOnTypesM replace
211 where
211 where
212 replace TypeWildcard = do
212 replace TypeWildcard = do
src/Language/PureScript/Types.hs+2−2
@@ -248,7 +248,7 @@ everywhereOnTypesTopDown f = go . f
248 go (PrettyPrintForAll args t) = PrettyPrintForAll args (go (f t))
248 go (PrettyPrintForAll args t) = PrettyPrintForAll args (go (f t))
249 go other = f other
249 go other = f other
250
250
251−everywhereOnTypesM :: (Functor m, Applicative m, Monad m) => (Type -> m Type) -> Type -> m Type
251+everywhereOnTypesM :: Monad m => (Type -> m Type) -> Type -> m Type
252everywhereOnTypesM f = go
252everywhereOnTypesM f = go
253 where
253 where
254 go (TypeApp t1 t2) = (TypeApp <$> go t1 <*> go t2) >>= f
254 go (TypeApp t1 t2) = (TypeApp <$> go t1 <*> go t2) >>= f
@@ -261,7 +261,7 @@ everywhereOnTypesM f = go
261 go (PrettyPrintForAll args t) = (PrettyPrintForAll args <$> go t) >>= f
261 go (PrettyPrintForAll args t) = (PrettyPrintForAll args <$> go t) >>= f
262 go other = f other
262 go other = f other
263
263
264−everywhereOnTypesTopDownM :: (Functor m, Applicative m, Monad m) => (Type -> m Type) -> Type -> m Type
264+everywhereOnTypesTopDownM :: Monad m => (Type -> m Type) -> Type -> m Type
265everywhereOnTypesTopDownM f = go <=< f
265everywhereOnTypesTopDownM f = go <=< f
266 where
266 where
267 go (TypeApp t1 t2) = TypeApp <$> (f t1 >>= go) <*> (f t2 >>= go)
267 go (TypeApp t1 t2) = TypeApp <$> (f t1 >>= go) <*> (f t2 >>= go)
stack-lts-2.yamldeleted−13
@@ -1,13 +0,0 @@
1−resolver: lts-2.22
2−packages:
3−- '.'
4−extra-deps:
5−- aeson-better-errors-0.8.0
6−- bower-json-0.7.0.0
7−- boxes-0.1.4
8−- pattern-arrows-0.0.2
9−- sourcemap-0.1.6
10−- fsnotify-0.2.1
11−- hfsevents-0.1.6
12−- pipes-http-1.0.2
13−flags: {}
stack-lts-3.yamldeleted−6
@@ -1,6 +0,0 @@
1−resolver: lts-3.22
2−packages:
3−- '.'
4−extra-deps:
5−- sourcemap-0.1.6
6−flags: {}