summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilFreeman <>2014-11-28 21:13:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-11-28 21:13:00 (GMT)
commitec83a8ba6a1e656a603ccbef6b6b4fdc4fe28bf1 (patch)
tree6a8d7f2e2bf927c2f3244190b6349ea72de31099
parent006fb5f4e9b1a956a896606949b3e028847183f9 (diff)
version 0.6.20.6.2
-rw-r--r--LICENSE602
-rw-r--r--examples/passing/NestedWhere.purs10
-rw-r--r--examples/passing/STArray.purs25
-rw-r--r--hierarchy/Main.hs54
-rw-r--r--prelude/prelude.purs35
-rw-r--r--psc-docs/Main.hs47
-rw-r--r--psc-make/Main.hs128
-rw-r--r--psc/Main.hs200
-rw-r--r--psci/Main.hs80
-rw-r--r--purescript.cabal28
-rw-r--r--src/Language/PureScript/AST/Traversals.hs2
-rw-r--r--src/Language/PureScript/Constants.hs9
-rw-r--r--src/Language/PureScript/Optimizer/MagicDo.hs6
-rw-r--r--src/Language/PureScript/Sugar/BindingGroups.hs58
14 files changed, 967 insertions, 317 deletions
diff --git a/LICENSE b/LICENSE
index 6e34c48..3bb98e7 100644
--- a/LICENSE
+++ b/LICENSE
@@ -18,3 +18,605 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+PureScript uses the following Haskell library packages. Their license files follow.
+
+ base
+ containers
+ directory
+ file-embed
+ filepath
+ haskeline
+ monad-unify
+ mtl
+ optparse-applicative
+ parsec
+ pattern-arrows
+ process
+ time
+ transformers
+ unordered-containers
+ utf8-string
+
+base LICENSE file:
+
+ This library (libraries/base) is derived from code from several
+ sources:
+
+ * Code from the GHC project which is largely (c) The University of
+ Glasgow, and distributable under a BSD-style license (see below),
+
+ * Code from the Haskell 98 Report which is (c) Simon Peyton Jones
+ and freely redistributable (but see the full license for
+ restrictions).
+
+ * Code from the Haskell Foreign Function Interface specification,
+ which is (c) Manuel M. T. Chakravarty and freely redistributable
+ (but see the full license for restrictions).
+
+ The full text of these licenses is reproduced below. All of the
+ licenses are BSD-style or compatible.
+
+ -----------------------------------------------------------------------------
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+ -----------------------------------------------------------------------------
+
+ Code derived from the document "Report on the Programming Language
+ Haskell 98", is distributed under the following license:
+
+ Copyright (c) 2002 Simon Peyton Jones
+
+ The authors intend this Report to belong to the entire Haskell
+ community, and so we grant permission to copy and distribute it for
+ any purpose, provided that it is reproduced in its entirety,
+ including this Notice. Modified versions of this Report may also be
+ copied and distributed for any purpose, provided that the modified
+ version is clearly presented as such, and that it does not claim to
+ be a definition of the Haskell 98 Language.
+
+ -----------------------------------------------------------------------------
+
+ Code derived from the document "The Haskell 98 Foreign Function
+ Interface, An Addendum to the Haskell 98 Report" is distributed under
+ the following license:
+
+ Copyright (c) 2002 Manuel M. T. Chakravarty
+
+ The authors intend this Report to belong to the entire Haskell
+ community, and so we grant permission to copy and distribute it for
+ any purpose, provided that it is reproduced in its entirety,
+ including this Notice. Modified versions of this Report may also be
+ copied and distributed for any purpose, provided that the modified
+ version is clearly presented as such, and that it does not claim to
+ be a definition of the Haskell 98 Foreign Function Interface.
+
+ -----------------------------------------------------------------------------
+
+containers LICENSE file:
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+directory LICENSE file:
+
+ This library (libraries/base) is derived from code from two
+ sources:
+
+ * Code from the GHC project which is largely (c) The University of
+ Glasgow, and distributable under a BSD-style license (see below),
+
+ * Code from the Haskell 98 Report which is (c) Simon Peyton Jones
+ and freely redistributable (but see the full license for
+ restrictions).
+
+ The full text of these licenses is reproduced below. Both of the
+ licenses are BSD-style or compatible.
+
+ -----------------------------------------------------------------------------
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+ -----------------------------------------------------------------------------
+
+ Code derived from the document "Report on the Programming Language
+ Haskell 98", is distributed under the following license:
+
+ Copyright (c) 2002 Simon Peyton Jones
+
+ The authors intend this Report to belong to the entire Haskell
+ community, and so we grant permission to copy and distribute it for
+ any purpose, provided that it is reproduced in its entirety,
+ including this Notice. Modified versions of this Report may also be
+ copied and distributed for any purpose, provided that the modified
+ version is clearly presented as such, and that it does not claim to
+ be a definition of the Haskell 98 Language.
+
+ -----------------------------------------------------------------------------
+
+file-embed LICENSE file:
+
+ The following license covers this documentation, and the source code, except
+ where otherwise indicated.
+
+ Copyright 2008, Michael Snoyman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+filepath LICENSE file:
+
+ Copyright Neil Mitchell 2005-2007.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Neil Mitchell nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+haskeline LICENSE file:
+
+ Copyright 2007-2009, Judah Jacobson.
+ All Rights Reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistribution of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistribution in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+monad-unify LICENSE file:
+
+ The MIT License (MIT)
+
+ Copyright (c) 2013 Phil Freeman
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+mtl LICENSE file:
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+optparse-applicative LICENSE file:
+
+ Copyright (c) 2012, Paolo Capriotti
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Paolo Capriotti nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+parsec LICENSE file:
+
+ Copyright 1999-2000, Daan Leijen; 2007, Paolo Martini. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ This software is provided by the copyright holders "as is" and any express or
+ implied warranties, including, but not limited to, the implied warranties of
+ merchantability and fitness for a particular purpose are disclaimed. In no
+ event shall the copyright holders be liable for any direct, indirect,
+ incidental, special, exemplary, or consequential damages (including, but not
+ limited to, procurement of substitute goods or services; loss of use, data,
+ or profits; or business interruption) however caused and on any theory of
+ liability, whether in contract, strict liability, or tort (including
+ negligence or otherwise) arising in any way out of the use of this software,
+ even if advised of the possibility of such damage.
+
+pattern-arrows LICENSE file:
+
+ The MIT License (MIT)
+
+ Copyright (c) 2013 Phil Freeman
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+process LICENSE file:
+
+ This library (libraries/process) is derived from code from two
+ sources:
+
+ * Code from the GHC project which is largely (c) The University of
+ Glasgow, and distributable under a BSD-style license (see below),
+
+ * Code from the Haskell 98 Report which is (c) Simon Peyton Jones
+ and freely redistributable (but see the full license for
+ restrictions).
+
+ The full text of these licenses is reproduced below. Both of the
+ licenses are BSD-style or compatible.
+
+ -----------------------------------------------------------------------------
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+ -----------------------------------------------------------------------------
+
+ Code derived from the document "Report on the Programming Language
+ Haskell 98", is distributed under the following license:
+
+ Copyright (c) 2002 Simon Peyton Jones
+
+ The authors intend this Report to belong to the entire Haskell
+ community, and so we grant permission to copy and distribute it for
+ any purpose, provided that it is reproduced in its entirety,
+ including this Notice. Modified versions of this Report may also be
+ copied and distributed for any purpose, provided that the modified
+ version is clearly presented as such, and that it does not claim to
+ be a definition of the Haskell 98 Language.
+
+ -----------------------------------------------------------------------------
+
+time LICENSE file:
+
+ TimeLib is Copyright (c) Ashley Yakeley, 2004-2014. All rights reserved.
+ Certain sections are Copyright 2004, The University Court of the University of Glasgow. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+ - Neither name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+transformers LICENSE file:
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+unordered-containers LICENSE file:
+
+ Copyright (c) 2010, Johan Tibell
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Johan Tibell nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+utf8-string LICENSE file:
+
+ * Copyright (c) 2007, Galois Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Galois Inc. nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Galois Inc. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Galois Inc. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/examples/passing/NestedWhere.purs b/examples/passing/NestedWhere.purs
new file mode 100644
index 0000000..e50b5f0
--- /dev/null
+++ b/examples/passing/NestedWhere.purs
@@ -0,0 +1,10 @@
+module Main where
+
+f x = g x
+ where
+ g x = go x
+ where
+ go x = go1 (x - 1)
+ go1 x = go x
+
+main = Debug.Trace.trace "Done"
diff --git a/examples/passing/STArray.purs b/examples/passing/STArray.purs
deleted file mode 100644
index a2bfdd5..0000000
--- a/examples/passing/STArray.purs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Main where
-
-import Prelude
-import Control.Monad.Eff
-import Control.Monad.ST
-import Debug.Trace
-
-test = runSTArray (do
- a <- newSTArray 2 0
- pokeSTArray a 0 1
- pokeSTArray a 1 2
- return a)
-
-fromTo lo hi = runSTArray (do
- arr <- newSTArray (hi - lo + 1) 0
- (let
- go lo hi _ arr | lo > hi = return arr
- go lo hi i arr = do
- pokeSTArray arr i lo
- go (lo + 1) hi (i + 1) arr
- in go lo hi 0 arr))
-
-main = do
- let t1 = runPure (fromTo 10 20)
- trace "Done"
diff --git a/hierarchy/Main.hs b/hierarchy/Main.hs
index e015607..b60cf16 100644
--- a/hierarchy/Main.hs
+++ b/hierarchy/Main.hs
@@ -15,25 +15,30 @@
module Main where
-import Control.Applicative ((<*>), (<$>))
import Control.Monad (unless)
import Data.List (intercalate,nub,sort)
import Data.Foldable (for_)
import Data.Version (showVersion)
-import System.Console.CmdTheLine
+import Options.Applicative
import System.Directory (createDirectoryIfMissing)
import System.FilePath ((</>))
import System.Exit (exitFailure, exitSuccess)
import System.IO (stderr)
-import Text.Parsec (ParseError)
+import Text.Parsec as Par (ParseError)
import qualified Language.PureScript as P
import qualified Paths_purescript as Paths
import qualified System.IO.UTF8 as U
+
+data HierarchyOptions = HierarchyOptions
+ { hierachyInput :: FilePath
+ , hierarchyOutput :: Maybe FilePath
+ }
+
newtype SuperMap = SuperMap { unSuperMap :: Either P.ProperName (P.ProperName, P.ProperName) }
deriving Eq
@@ -49,13 +54,13 @@ instance Ord SuperMap where
runModuleName :: P.ModuleName -> String
runModuleName (P.ModuleName pns) = intercalate "_" (P.runProperName `map` pns)
-readInput :: FilePath -> IO (Either ParseError [P.Module])
+readInput :: FilePath -> IO (Either Par.ParseError [P.Module])
readInput p = do
text <- U.readFile p
return $ P.runIndentParser p P.parseModules text
-compile :: FilePath -> Maybe FilePath -> IO ()
-compile input mOutput = do
+compile :: HierarchyOptions -> IO ()
+compile (HierarchyOptions input mOutput) = do
modules <- readInput input
case modules of
Left err -> U.hPutStr stderr (show err) >> exitFailure
@@ -82,23 +87,28 @@ superClasses (P.TypeClassDeclaration sub _ _ _) = [SuperMap (Left sub)]
superClasses (P.PositionedDeclaration _ decl) = superClasses decl
superClasses _ = []
-outputFile :: Term (Maybe FilePath)
-outputFile = value $ opt Nothing $ (optInfo [ "o", "output" ])
- { optDoc = "The output directory" }
+inputFile :: Parser FilePath
+inputFile = strArgument $
+ metavar "FILE"
+ <> value "main.purs"
+ <> showDefault
+ <> help "The input file to generate a hierarchy from"
-inputFile :: Term FilePath
-inputFile = value $ pos 0 "main.purs" $ posInfo
- { posDoc = "The input file to generate a hierarchy from" }
+outputFile :: Parser (Maybe FilePath)
+outputFile = optional . strOption $
+ short 'o'
+ <> long "output"
+ <> help "The output directory"
-term :: Term (IO ())
-term = compile <$> inputFile <*> outputFile
-
-termInfo :: TermInfo
-termInfo = defTI
- { termName = "hierarchy"
- , version = showVersion Paths.version
- , termDoc = "Creates a GraphViz directed graph of PureScript TypeClasses"
- }
+pscOptions :: Parser HierarchyOptions
+pscOptions = HierarchyOptions <$> inputFile
+ <*> outputFile
main :: IO ()
-main = run (term, termInfo)
+main = execParser opts >>= compile
+ where
+ opts = info (helper <*> pscOptions) infoModList
+ infoModList = fullDesc <> headerInfo <> footerInfo
+ headerInfo = header "hierarchy - Creates a GraphViz directed graph of PureScript TypeClasses"
+ footerInfo = footer $ "hierarchy " ++ showVersion Paths.version
+
diff --git a/prelude/prelude.purs b/prelude/prelude.purs
index 54c96f8..85b8a00 100644
--- a/prelude/prelude.purs
+++ b/prelude/prelude.purs
@@ -883,8 +883,6 @@ module Control.Monad.ST where
foreign import data STRef :: * -> * -> *
- foreign import data STArray :: * -> * -> *
-
foreign import newSTRef "function newSTRef(val) {\
\ return function() {\
\ return { value: val };\
@@ -913,40 +911,7 @@ module Control.Monad.ST where
\ };\
\}" :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
- foreign import newSTArray "function newSTArray(len) {\
- \ return function(a) {\
- \ return function() {\
- \ var arr = [];\
- \ for (var i = 0; i < len; i++) {\
- \ arr[i] = a;\
- \ };\
- \ return arr;\
- \ };\
- \ };\
- \}" :: forall a h r. Number -> a -> Eff (st :: ST h | r) (STArray h a)
-
- foreign import peekSTArray "function peekSTArray(arr) {\
- \ return function(i) {\
- \ return function() {\
- \ return arr[i];\
- \ };\
- \ };\
- \}" :: forall a h r. STArray h a -> Number -> Eff (st :: ST h | r) a
-
- foreign import pokeSTArray "function pokeSTArray(arr) {\
- \ return function(i) {\
- \ return function(a) {\
- \ return function() {\
- \ return arr[i] = a;\
- \ };\
- \ };\
- \ };\
- \}" :: forall a h r. STArray h a -> Number -> a -> Eff (st :: ST h | r) a
-
foreign import runST "function runST(f) {\
\ return f;\
\}" :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
- foreign import runSTArray "function runSTArray(f) {\
- \ return f;\
- \}" :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r [a]
diff --git a/psc-docs/Main.hs b/psc-docs/Main.hs
index 7a2b7de..d40ea17 100644
--- a/psc-docs/Main.hs
+++ b/psc-docs/Main.hs
@@ -22,15 +22,24 @@ import Data.Function (on)
import Data.List
import Data.Maybe (fromMaybe)
import Data.Version (showVersion)
+
+import Options.Applicative
+
import qualified Language.PureScript as P
import qualified Paths_purescript as Paths
import qualified System.IO.UTF8 as U
-import System.Console.CmdTheLine
import System.Exit (exitSuccess, exitFailure)
import System.IO (stderr)
-docgen :: Bool -> [FilePath] -> IO ()
-docgen showHierarchy input = do
+
+data PSCDocsOptions = PSCDocsOptions
+ { pscdIncludeHeir :: Bool
+ , pscdInputFiles :: [FilePath]
+ }
+
+
+docgen :: PSCDocsOptions -> IO ()
+docgen (PSCDocsOptions showHierarchy input) = do
e <- P.parseModulesFromFiles (fromMaybe "") <$> mapM (fmap (first Just) . parseFile) (nub input)
case e of
Left err -> do
@@ -218,21 +227,25 @@ isTypeInstanceDeclaration P.TypeInstanceDeclaration{} = True
isTypeInstanceDeclaration (P.PositionedDeclaration _ d) = isTypeInstanceDeclaration d
isTypeInstanceDeclaration _ = False
-inputFiles :: Term [FilePath]
-inputFiles = value $ posAny [] $ posInfo { posName = "file(s)", posDoc = "The input .purs file(s)" }
-
-includeHeirarcy :: Term Bool
-includeHeirarcy = value $ flag $ (optInfo [ "h", "hierarchy-images" ]) { optDoc = "Include markdown for type class hierarchy images in the output." }
+inputFile :: Parser FilePath
+inputFile = strArgument $
+ metavar "FILE"
+ <> help "The input .ps file(s)"
-term :: Term (IO ())
-term = docgen <$> includeHeirarcy <*> inputFiles
+includeHeirarcy :: Parser Bool
+includeHeirarcy = switch $
+ long "hierarchy-images"
+ <> help "Include markdown for type class hierarchy images in the output."
-termInfo :: TermInfo
-termInfo = defTI
- { termName = "psc-docs"
- , version = showVersion Paths.version
- , termDoc = "Generate Markdown documentation from PureScript extern files"
- }
+pscDocsOptions :: Parser PSCDocsOptions
+pscDocsOptions = PSCDocsOptions <$> includeHeirarcy
+ <*> many inputFile
main :: IO ()
-main = run (term, termInfo)
+main = execParser opts >>= docgen
+ where
+ opts = info (helper <*> pscDocsOptions) infoModList
+ infoModList = fullDesc <> headerInfo <> footerInfo
+ headerInfo = header "psc-docs - Generate Markdown documentation from PureScript extern files"
+ footerInfo = footer $ "psc-docs " ++ showVersion Paths.version
+
diff --git a/psc-make/Main.hs b/psc-make/Main.hs
index f56efb5..eddbb4a 100644
--- a/psc-make/Main.hs
+++ b/psc-make/Main.hs
@@ -21,7 +21,8 @@ import Control.Monad.Error
import Data.Version (showVersion)
-import System.Console.CmdTheLine
+import Options.Applicative as Opts
+
import System.Directory
(doesFileExist, getModificationTime, createDirectoryIfMissing)
import System.FilePath (takeDirectory)
@@ -32,6 +33,14 @@ import qualified Language.PureScript as P
import qualified Paths_purescript as Paths
import qualified System.IO.UTF8 as U
+
+data PSCMakeOptions = PSCMakeOptions
+ { pscmInput :: [FilePath]
+ , pscmOutputDir :: FilePath
+ , pscmOpts :: P.Options P.Make
+ , pscmUsePrefix :: Bool
+ }
+
data InputOptions = InputOptions
{ ioNoPrelude :: Bool
, ioInputFiles :: [FilePath]
@@ -39,7 +48,7 @@ data InputOptions = InputOptions
readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
readInput InputOptions{..} = do
- content <- forM ioInputFiles $ \inputFile -> (Right inputFile, ) <$> U.readFile inputFile
+ content <- forM ioInputFiles $ \inFile -> (Right inFile, ) <$> U.readFile inFile
return (if ioNoPrelude then content else (Left P.RebuildNever, P.prelude) : content)
newtype Make a = Make { unMake :: ErrorT String IO a } deriving (Functor, Applicative, Monad, MonadIO, MonadError String)
@@ -66,8 +75,8 @@ instance P.MonadMake Make where
liftError = either throwError return
progress = makeIO . U.putStrLn
-compile :: [FilePath] -> FilePath -> P.Options P.Make -> Bool -> IO ()
-compile input outputDir opts usePrefix = do
+compile :: PSCMakeOptions -> IO ()
+compile (PSCMakeOptions input outputDir opts usePrefix) = do
modules <- P.parseModulesFromFiles (either (const "") id) <$> readInput (InputOptions (P.optionsNoPrelude opts) input)
case modules of
Left err -> do
@@ -89,51 +98,72 @@ compile input outputDir opts usePrefix = do
mkdirp :: FilePath -> IO ()
mkdirp = createDirectoryIfMissing True . takeDirectory
-inputFiles :: Term [FilePath]
-inputFiles = value $ posAny [] $ posInfo
- { posDoc = "The input .ps files" }
-
-outputDirectory :: Term FilePath
-outputDirectory = value $ opt "output" $ (optInfo [ "o", "output" ])
- { optDoc = "The output directory" }
-
-noTco :: Term Bool
-noTco = value $ flag $ (optInfo [ "no-tco" ])
- { optDoc = "Disable tail call optimizations" }
-
-noPrelude :: Term Bool
-noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
- { optDoc = "Omit the Prelude" }
-
-noMagicDo :: Term Bool
-noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
- { optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
-
-noOpts :: Term Bool
-noOpts = value $ flag $ (optInfo [ "no-opts" ])
- { optDoc = "Skip the optimization phase." }
-
-verboseErrors :: Term Bool
-verboseErrors = value $ flag $ (optInfo [ "v", "verbose-errors" ])
- { optDoc = "Display verbose error messages" }
-
-options :: Term (P.Options P.Make)
-options = P.Options <$> noPrelude <*> noTco <*> noMagicDo <*> pure Nothing <*> noOpts <*> verboseErrors <*> pure P.MakeOptions
-
-noPrefix :: Term Bool
-noPrefix = value $ flag $ (optInfo ["p", "no-prefix" ])
- { optDoc = "Do not include comment header"}
-
-term :: Term (IO ())
-term = compile <$> inputFiles <*> outputDirectory <*> options <*> (not <$> noPrefix)
-
-termInfo :: TermInfo
-termInfo = defTI
- { termName = "psc-make"
- , version = showVersion Paths.version
- , termDoc = "Compiles PureScript to Javascript"
- }
+inputFile :: Parser FilePath
+inputFile = strArgument $
+ metavar "FILE"
+ <> help "The input .ps file(s)"
+
+outputDirectory :: Parser FilePath
+outputDirectory = strOption $
+ short 'o'
+ <> long "output"
+ <> Opts.value "output"
+ <> showDefault
+ <> help "The output directory"
+
+noTco :: Parser Bool
+noTco = switch $
+ long "no-tco"
+ <> help "Disable tail call optimizations"
+
+noPrelude :: Parser Bool
+noPrelude = switch $
+ long "no-prelude"
+ <> help "Omit the Prelude"
+
+noMagicDo :: Parser Bool
+noMagicDo = switch $
+ long "no-magic-do"
+ <> help "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad."
+
+noOpts :: Parser Bool
+noOpts = switch $
+ long "verbose-errors"
+ <> help "Skip the optimization phase."
+
+verboseErrors :: Parser Bool
+verboseErrors = switch $
+ short 'v'
+ <> long "no-opts"
+ <> help "Display verbose error messages"
+
+noPrefix :: Parser Bool
+noPrefix = switch $
+ short 'p'
+ <> long "no-prefix"
+ <> help "Do not include comment header"
+
+
+options :: Parser (P.Options P.Make)
+options = P.Options <$> noPrelude
+ <*> noTco
+ <*> noMagicDo
+ <*> pure Nothing
+ <*> noOpts
+ <*> verboseErrors
+ <*> pure P.MakeOptions
+
+pscMakeOptions :: Parser PSCMakeOptions
+pscMakeOptions = PSCMakeOptions <$> many inputFile
+ <*> outputDirectory
+ <*> options
+ <*> (not <$> noPrefix)
main :: IO ()
-main = run (term, termInfo)
+main = execParser opts >>= compile
+ where
+ opts = info (helper <*> pscMakeOptions) infoModList
+ infoModList = fullDesc <> headerInfo <> footerInfo
+ headerInfo = header "psc-make - Compiles PureScript to Javascript"
+ footerInfo = footer $ "psc-make " ++ showVersion Paths.version
diff --git a/psc/Main.hs b/psc/Main.hs
index 2a1d594..f1e2ee4 100644
--- a/psc/Main.hs
+++ b/psc/Main.hs
@@ -22,7 +22,7 @@ import Control.Monad.Error
import Data.Maybe (fromMaybe)
import Data.Version (showVersion)
-import System.Console.CmdTheLine
+import Options.Applicative as Opts
import System.Directory (createDirectoryIfMissing)
import System.FilePath (takeDirectory)
import System.Exit (exitSuccess, exitFailure)
@@ -32,6 +32,16 @@ import qualified Language.PureScript as P
import qualified Paths_purescript as Paths
import qualified System.IO.UTF8 as U
+
+data PSCOptions = PSCOptions
+ { pscInput :: [FilePath]
+ , pscOpts :: P.Options P.Compile
+ , pscStdIn :: Bool
+ , pscOutput :: Maybe FilePath
+ , pscExterns :: Maybe FilePath
+ , pscUsePrefix :: Bool
+ }
+
data InputOptions = InputOptions
{ ioNoPrelude :: Bool
, ioUseStdIn :: Bool
@@ -41,11 +51,11 @@ data InputOptions = InputOptions
readInput :: InputOptions -> IO [(Maybe FilePath, String)]
readInput InputOptions{..}
| ioUseStdIn = return . (Nothing ,) <$> getContents
- | otherwise = do content <- forM ioInputFiles $ \inputFile -> (Just inputFile, ) <$> U.readFile inputFile
+ | otherwise = do content <- forM ioInputFiles $ \inFile -> (Just inFile, ) <$> U.readFile inFile
return (if ioNoPrelude then content else (Nothing, P.prelude) : content)
-compile :: P.Options P.Compile -> Bool -> [FilePath] -> Maybe FilePath -> Maybe FilePath -> Bool -> IO ()
-compile opts stdin input output externs usePrefix = do
+compile :: PSCOptions -> IO ()
+compile (PSCOptions input opts stdin output externs usePrefix) = do
modules <- P.parseModulesFromFiles (fromMaybe "") <$> readInput (InputOptions (P.optionsNoPrelude opts) stdin input)
case modules of
Left err -> do
@@ -72,78 +82,118 @@ compile opts stdin input output externs usePrefix = do
mkdirp :: FilePath -> IO ()
mkdirp = createDirectoryIfMissing True . takeDirectory
-useStdIn :: Term Bool
-useStdIn = value . flag $ (optInfo [ "s", "stdin" ])
- { optDoc = "Read from standard input" }
-
-inputFiles :: Term [FilePath]
-inputFiles = value $ posAny [] $ posInfo
- { posDoc = "The input .ps files" }
-
-outputFile :: Term (Maybe FilePath)
-outputFile = value $ opt Nothing $ (optInfo [ "o", "output" ])
- { optDoc = "The output .js file" }
-
-externsFile :: Term (Maybe FilePath)
-externsFile = value $ opt Nothing $ (optInfo [ "e", "externs" ])
- { optDoc = "The output .e.ps file" }
-
-noTco :: Term Bool
-noTco = value $ flag $ (optInfo [ "no-tco" ])
- { optDoc = "Disable tail call optimizations" }
-
-noPrelude :: Term Bool
-noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
- { optDoc = "Omit the Prelude" }
-
-noMagicDo :: Term Bool
-noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
- { optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
-
-runMain :: Term (Maybe String)
-runMain = value $ defaultOpt (Just "Main") Nothing $ (optInfo [ "main" ])
- { optDoc = "Generate code to run the main method in the specified module." }
-
-noOpts :: Term Bool
-noOpts = value $ flag $ (optInfo [ "no-opts" ])
- { optDoc = "Skip the optimization phase." }
-
-browserNamespace :: Term String
-browserNamespace = value $ opt "PS" $ (optInfo [ "browser-namespace" ])
- { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
-
-dceModules :: Term [String]
-dceModules = value $ optAll [] $ (optInfo [ "m", "module" ])
- { optDoc = "Enables dead code elimination, all code which is not a transitive dependency of a specified module will be removed. This argument can be used multiple times." }
-
-codeGenModules :: Term [String]
-codeGenModules = value $ optAll [] $ (optInfo [ "codegen" ])
- { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
-
-verboseErrors :: Term Bool
-verboseErrors = value $ flag $ (optInfo [ "v", "verbose-errors" ])
- { optDoc = "Display verbose error messages" }
-
-noPrefix :: Term Bool
-noPrefix = value $ flag $ (optInfo ["no-prefix" ])
- { optDoc = "Do not include comment header"}
-
-options :: Term (P.Options P.Compile)
-options = P.Options <$> noPrelude <*> noTco <*> noMagicDo <*> runMain <*> noOpts <*> verboseErrors <*> additionalOptions
+codeGenModule :: Parser String
+codeGenModule = strOption $
+ long "codegen"
+ <> help "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times."
+
+dceModule :: Parser String
+dceModule = strOption $
+ short 'm'
+ <> long "module"
+ <> help "Enables dead code elimination, all code which is not a transitive dependency of a specified module will be removed. This argument can be used multiple times."
+
+browserNamespace :: Parser String
+browserNamespace = strOption $
+ long "browser-namespace"
+ <> Opts.value "PS"
+ <> showDefault
+ <> help "Specify the namespace that PureScript modules will be exported to when running in the browser."
+
+verboseErrors :: Parser Bool
+verboseErrors = switch $
+ short 'v'
+ <> long "verbose-errors"
+ <> help "Display verbose error messages"
+
+noOpts :: Parser Bool
+noOpts = switch $
+ long "no-opts"
+ <> help "Skip the optimization phase."
+
+runMain :: Parser (Maybe String)
+runMain = optional $ noArgs <|> withArgs
where
- additionalOptions = P.CompileOptions <$> browserNamespace <*> dceModules <*> codeGenModules
-
-term :: Term (IO ())
-term = compile <$> options <*> useStdIn <*> inputFiles <*> outputFile <*> externsFile <*> (not <$> noPrefix)
-
-termInfo :: TermInfo
-termInfo = defTI
- { termName = "psc"
- , version = showVersion Paths.version
- , termDoc = "Compiles PureScript to Javascript"
- }
+ defaultVal = "Main"
+ noArgs = flag' defaultVal (long "main")
+ withArgs = strOption $
+ long "main"
+ <> help (concat [
+ "Generate code to run the main method in the specified module. ",
+ "(no argument: \"", defaultVal, "\")"
+ ])
+
+noMagicDo :: Parser Bool
+noMagicDo = switch $
+ long "no-magic-do"
+ <> help "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad."
+
+noTco :: Parser Bool
+noTco = switch $
+ long "no-tco"
+ <> help "Disable tail call optimizations"
+
+noPrelude :: Parser Bool
+noPrelude = switch $
+ long "no-prelude"
+ <> help "Omit the Prelude"
+
+useStdIn :: Parser Bool
+useStdIn = switch $
+ short 's'
+ <> long "stdin"
+ <> help "Read from standard input"
+
+inputFile :: Parser FilePath
+inputFile = strArgument $
+ metavar "FILE"
+ <> help "The input .ps file(s)"
+
+outputFile :: Parser (Maybe FilePath)
+outputFile = optional . strOption $
+ short 'o'
+ <> long "output"
+ <> help "The output .js file"
+
+externsFile :: Parser (Maybe FilePath)
+externsFile = optional . strOption $
+ short 'e'
+ <> long "externs"
+ <> help "The output .e.ps file"
+
+noPrefix :: Parser Bool
+noPrefix = switch $
+ short 'p'
+ <> long "no-prefix"
+ <> help "Do not include comment header"
+
+options :: Parser (P.Options P.Compile)
+options = P.Options <$> noPrelude
+ <*> noTco
+ <*> noMagicDo
+ <*> runMain
+ <*> noOpts
+ <*> verboseErrors
+ <*> additionalOptions
+ where
+ additionalOptions =
+ P.CompileOptions <$> browserNamespace
+ <*> many dceModule
+ <*> many codeGenModule
+
+pscOptions :: Parser PSCOptions
+pscOptions = PSCOptions <$> many inputFile
+ <*> options
+ <*> useStdIn
+ <*> outputFile
+ <*> externsFile
+ <*> (not <$> noPrefix)
main :: IO ()
-main = run (term, termInfo)
-
+main = execParser opts >>= compile
+ where
+ opts = info (helper <*> pscOptions) infoModList
+ infoModList = fullDesc <> headerInfo <> footerInfo
+ headerInfo = header "psc - Compiles PureScript to Javascript"
+ footerInfo = footer $ "psc " ++ showVersion Paths.version
diff --git a/psci/Main.hs b/psci/Main.hs
index f52be1a..2206257 100644
--- a/psci/Main.hs
+++ b/psci/Main.hs
@@ -33,25 +33,32 @@ import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
import Control.Monad.Trans.State.Strict
import qualified Control.Monad.Trans.State.Lazy as L
+import Options.Applicative as Opts
+
import System.Console.Haskeline
import System.Directory (createDirectoryIfMissing, getModificationTime, doesFileExist, findExecutable, getHomeDirectory, getCurrentDirectory)
import System.Exit
import System.FilePath (pathSeparator, takeDirectory, (</>), isPathSeparator)
import System.IO.Error (tryIOError)
import System.Process (readProcessWithExitCode)
-import qualified System.Console.CmdTheLine as Cmd
import qualified System.IO.UTF8 as U (writeFile, putStrLn, print, readFile)
-import Text.Parsec (ParseError)
+import qualified Text.Parsec as Par (ParseError)
import qualified Language.PureScript as P
import qualified Language.PureScript.AST as D
import qualified Language.PureScript.Names as N
import qualified Paths_purescript as Paths
-import Commands
+import Commands as C
import Parser
+
+data PSCiOptions = PSCiOptions
+ { psciSingleLineFlag :: Bool
+ , psciInputFile :: [FilePath]
+ }
+
-- |
-- The PSCI state.
-- Holds a list of imported modules, loaded files, and partial let bindings.
@@ -125,7 +132,7 @@ loadModule filename = either (Left . show) Right . P.runIndentParser filename P.
-- |
-- Load all modules, including the Prelude
--
-loadAllModules :: [FilePath] -> IO (Either ParseError [(Either P.RebuildPolicy FilePath, P.Module)])
+loadAllModules :: [FilePath] -> IO (Either Par.ParseError [(Either P.RebuildPolicy FilePath, P.Module)])
loadAllModules files = do
filesAndContent <- forM files $ \filename -> do
content <- U.readFile filename
@@ -146,7 +153,7 @@ expandTilde p = return p
--
helpMessage :: String
helpMessage = "The following commands are available:\n\n " ++
- intercalate "\n " (map (intercalate " ") help)
+ intercalate "\n " (map (intercalate " ") C.help)
-- |
-- The welcome prologue.
@@ -180,10 +187,10 @@ completion :: CompletionFunc (StateT PSCiState IO)
completion = completeWord Nothing " \t\n\r" findCompletions
where
findCompletions :: String -> StateT PSCiState IO [Completion]
- findCompletions str = do
+ findCompletions st = do
ms <- map snd . psciLoadedModules <$> get
- files <- listFiles str
- let matches = filter (isPrefixOf str) (names ms)
+ files <- listFiles st
+ let matches = filter (isPrefixOf st) (names ms)
return $ sortBy sorter $ map simpleCompletion matches ++ files
getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
getDeclName Nothing (P.ValueDeclaration ident _ _ _) = Just ident
@@ -248,13 +255,13 @@ mkdirp = createDirectoryIfMissing True . takeDirectory
-- Makes a volatile module to execute the current expression.
--
createTemporaryModule :: Bool -> PSCiState -> P.Expr -> P.Module
-createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetBindings = lets} value =
+createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetBindings = lets} val =
let
moduleName = P.ModuleName [P.ProperName "$PSCI"]
importDecl m = P.ImportDeclaration m P.Unqualified Nothing
traceModule = P.ModuleName [P.ProperName "Debug", P.ProperName "Trace"]
trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
- itValue = foldl (\x f -> f x) value lets
+ itValue = foldl (\x f -> f x) val lets
mainValue = P.App trace (P.Var (P.Qualified Nothing (P.Ident "it")))
itDecl = P.ValueDeclaration (P.Ident "it") P.Value [] $ Right itValue
mainDecl = P.ValueDeclaration (P.Ident "main") P.Value [] $ Right mainValue
@@ -295,9 +302,9 @@ indexFile = ".psci_modules" ++ pathSeparator : "index.js"
-- Takes a value declaration and evaluates it with the current state.
--
handleDeclaration :: P.Expr -> PSCI ()
-handleDeclaration value = do
+handleDeclaration val = do
st <- PSCI $ lift get
- let m = createTemporaryModule True st value
+ let m = createTemporaryModule True st val
e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [(Left P.RebuildAlways, m)]) []
case e of
Left err -> PSCI $ outputStrLn err
@@ -363,9 +370,9 @@ handleImport moduleName = do
-- Takes a value and prints its type
--
handleTypeOf :: P.Expr -> PSCI ()
-handleTypeOf value = do
+handleTypeOf val = do
st <- PSCI $ lift get
- let m = createTemporaryModule False st value
+ let m = createTemporaryModule False st val
e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [(Left P.RebuildAlways, m)]) []
case e of
Left err -> PSCI $ outputStrLn err
@@ -434,7 +441,7 @@ handleKindOf typ = do
-- |
-- Parses the input and returns either a Metacommand or an expression.
--
-getCommand :: Bool -> InputT (StateT PSCiState IO) (Either ParseError (Maybe Command))
+getCommand :: Bool -> InputT (StateT PSCiState IO) (Either Par.ParseError (Maybe Command))
getCommand singleLineMode = do
firstLine <- getInputLine "> "
case firstLine of
@@ -478,17 +485,6 @@ handleCommand (Show "loaded") = handleShowLoadedModules
handleCommand (Show "import") = handleShowImportedModules
handleCommand _ = PSCI $ outputStrLn "Unknown command"
-singleLineFlag :: Cmd.Term Bool
-singleLineFlag = Cmd.value $ Cmd.flag $ (Cmd.optInfo ["single-line-mode"])
- { Cmd.optName = "Single-line mode"
- , Cmd.optDoc = "Run in single-line mode"
- }
-
-inputFiles :: Cmd.Term [FilePath]
-inputFiles = Cmd.value $ Cmd.posAny [] $ Cmd.posInfo { Cmd.posName = "file(s)"
- , Cmd.posDoc = "Optional .purs files to load on start"
- }
-
loadUserConfig :: IO (Maybe [Command])
loadUserConfig = do
configFile <- (</> ".psci") <$> getCurrentDirectory
@@ -505,8 +501,8 @@ loadUserConfig = do
-- |
-- The PSCI main loop.
--
-loop :: Bool -> [FilePath] -> IO ()
-loop singleLineMode files = do
+loop :: PSCiOptions -> IO ()
+loop (PSCiOptions singleLineMode files) = do
config <- loadUserConfig
modulesOrFirstError <- loadAllModules files
case modulesOrFirstError of
@@ -528,15 +524,25 @@ loop singleLineMode files = do
Right (Just Quit) -> outputStrLn quitMessage
Right (Just c') -> runPSCI (handleCommand c') >> go
-term :: Cmd.Term (IO ())
-term = loop <$> singleLineFlag <*> inputFiles
+singleLineFlag :: Parser Bool
+singleLineFlag = switch $
+ long "single-line-mode"
+ <> Opts.help "Run in single-line mode"
-termInfo :: Cmd.TermInfo
-termInfo = Cmd.defTI
- { Cmd.termName = "psci"
- , Cmd.version = showVersion Paths.version
- , Cmd.termDoc = "Interactive mode for PureScript"
- }
+inputFile :: Parser FilePath
+inputFile = strArgument $
+ metavar "FILE"
+ <> Opts.help "Optional .purs files to load on start"
+
+psciOptions :: Parser PSCiOptions
+psciOptions = PSCiOptions <$> singleLineFlag
+ <*> many inputFile
main :: IO ()
-main = Cmd.run (term, termInfo)
+main = execParser opts >>= loop
+ where
+ opts = info (helper <*> psciOptions) infoModList
+ infoModList = fullDesc <> headerInfo <> footerInfo
+ headerInfo = header "psci - Interactive mode for PureScript"
+ footerInfo = footer $ "psci " ++ showVersion Paths.version
+
diff --git a/purescript.cabal b/purescript.cabal
index c5d4c3d..2cfb3d9 100644
--- a/purescript.cabal
+++ b/purescript.cabal
@@ -1,5 +1,5 @@
name: purescript
-version: 0.6.1.2
+version: 0.6.2
cabal-version: >=1.8
build-type: Simple
license: MIT
@@ -25,7 +25,6 @@ source-repository head
library
build-depends: base >=4.6 && <5,
- cmdtheline == 0.2.*,
containers -any,
unordered-containers -any,
directory >= 1.2,
@@ -107,9 +106,9 @@ library
ghc-options: -Wall -O2
executable psc
- build-depends: base >=4 && <5, cmdtheline -any, containers -any,
- directory -any, filepath -any, mtl -any, parsec -any,
- purescript -any, transformers -any, utf8-string -any
+ build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
+ mtl -any, optparse-applicative -any, parsec -any, purescript -any,
+ transformers -any, utf8-string -any
main-is: Main.hs
buildable: True
hs-source-dirs: psc
@@ -117,9 +116,9 @@ executable psc
ghc-options: -Wall -O2 -fno-warn-unused-do-bind
executable psc-make
- build-depends: base >=4 && <5, cmdtheline -any, containers -any,
- directory -any, filepath -any, mtl -any, parsec -any,
- purescript -any, transformers -any, utf8-string -any
+ build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
+ mtl -any, optparse-applicative -any, parsec -any, purescript -any,
+ transformers -any, utf8-string -any
main-is: Main.hs
buildable: True
hs-source-dirs: psc-make
@@ -128,9 +127,10 @@ executable psc-make
executable psci
build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
- mtl -any, parsec -any, haskeline >= 0.7.0.0, purescript -any,
- transformers -any, utf8-string -any, process -any,
- cmdtheline -any
+ mtl -any, optparse-applicative -any, parsec -any,
+ haskeline >= 0.7.0.0, purescript -any, transformers -any,
+ utf8-string -any, process -any
+
main-is: Main.hs
buildable: True
hs-source-dirs: psci
@@ -139,8 +139,8 @@ executable psci
ghc-options: -Wall -O2
executable psc-docs
- build-depends: base >=4 && <5, cmdtheline -any, purescript -any, utf8-string -any,
- process -any, mtl -any
+ build-depends: base >=4 && <5, purescript -any, utf8-string -any,
+ optparse-applicative -any, process -any, mtl -any
main-is: Main.hs
buildable: True
hs-source-dirs: psc-docs
@@ -148,7 +148,7 @@ executable psc-docs
ghc-options: -Wall -O2
executable hierarchy
- build-depends: base >=4 && <5, cmdtheline -any, purescript -any, utf8-string -any,
+ build-depends: base >=4 && <5, purescript -any, utf8-string -any, optparse-applicative -any,
process -any, mtl -any, parsec -any, filepath -any, directory -any
main-is: Main.hs
buildable: True
diff --git a/src/Language/PureScript/AST/Traversals.hs b/src/Language/PureScript/AST/Traversals.hs
index 464d7f0..1e4b868 100644
--- a/src/Language/PureScript/AST/Traversals.hs
+++ b/src/Language/PureScript/AST/Traversals.hs
@@ -135,7 +135,7 @@ everywhereOnValuesM :: (Functor m, Applicative m, Monad m) =>
(Expr -> m Expr) ->
(Binder -> m Binder) ->
(Declaration -> m Declaration, Expr -> m Expr, Binder -> m Binder)
-everywhereOnValuesM f g h = (f' <=< f, g' <=< g, h' <=< h)
+everywhereOnValuesM f g h = (f', g', h')
where
f' (DataBindingGroupDeclaration ds) = (DataBindingGroupDeclaration <$> mapM f' ds) >>= f
f' (ValueDeclaration name nameKind bs val) = (ValueDeclaration name nameKind <$> mapM h' bs <*> eitherM (mapM (pairM g' g')) g' val) >>= f
diff --git a/src/Language/PureScript/Constants.hs b/src/Language/PureScript/Constants.hs
index 2c0d5ae..fb4952b 100644
--- a/src/Language/PureScript/Constants.hs
+++ b/src/Language/PureScript/Constants.hs
@@ -123,9 +123,6 @@ whileE = "whileE"
runST :: String
runST = "runST"
-runSTArray :: String
-runSTArray = "runSTArray"
-
stRefValue :: String
stRefValue = "value"
@@ -141,12 +138,6 @@ writeSTRef = "writeSTRef"
modifySTRef :: String
modifySTRef = "modifySTRef"
-peekSTArray :: String
-peekSTArray = "peekSTArray"
-
-pokeSTArray :: String
-pokeSTArray = "pokeSTArray"
-
mkFn :: String
mkFn = "mkFn"
diff --git a/src/Language/PureScript/Optimizer/MagicDo.hs b/src/Language/PureScript/Optimizer/MagicDo.hs
index d09e74b..3a120a3 100644
--- a/src/Language/PureScript/Optimizer/MagicDo.hs
+++ b/src/Language/PureScript/Optimizer/MagicDo.hs
@@ -119,7 +119,7 @@ inlineST = everywhereOnJS convertBlock
-- Look for runST blocks and inline the STRefs there.
-- If all STRefs are used in the scope of the same runST, only using { read, write, modify }STRef then
-- we can be more aggressive about inlining, and actually turn STRefs into local variables.
- convertBlock (JSApp f [arg]) | isSTFunc C.runST f || isSTFunc C.runSTArray f =
+ convertBlock (JSApp f [arg]) | isSTFunc C.runST f =
let refs = nub . findSTRefsIn $ arg
usages = findAllSTUsagesIn arg
allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
@@ -137,10 +137,6 @@ inlineST = everywhereOnJS convertBlock
if agg then JSAssignment ref arg else JSAssignment (JSAccessor C.stRefValue ref) arg
convert agg (JSApp (JSApp (JSApp f [ref]) [func]) []) | isSTFunc C.modifySTRef f =
if agg then JSAssignment ref (JSApp func [ref]) else JSAssignment (JSAccessor C.stRefValue ref) (JSApp func [JSAccessor C.stRefValue ref])
- convert _ (JSApp (JSApp (JSApp f [arr]) [i]) []) | isSTFunc C.peekSTArray f =
- JSIndexer i arr
- convert _ (JSApp (JSApp (JSApp (JSApp f [arr]) [i]) [val]) []) | isSTFunc C.pokeSTArray f =
- JSAssignment (JSIndexer i arr) val
convert _ other = other
-- Check if an expression represents a function in the ST module
isSTFunc name (JSAccessor name' (JSVar st)) = st == C.st && name == name'
diff --git a/src/Language/PureScript/Sugar/BindingGroups.hs b/src/Language/PureScript/Sugar/BindingGroups.hs
index c7df1b1..fe0743a 100644
--- a/src/Language/PureScript/Sugar/BindingGroups.hs
+++ b/src/Language/PureScript/Sugar/BindingGroups.hs
@@ -26,6 +26,7 @@ import Data.List (nub, intersect)
import Data.Maybe (isJust, mapMaybe)
import Data.Monoid ((<>))
import Control.Applicative ((<$>), (<*>), pure)
+import Control.Monad ((<=<))
import qualified Data.Set as S
@@ -47,35 +48,37 @@ createBindingGroupsModule = mapM $ \(Module name ds exps) -> Module name <$> cre
collapseBindingGroupsModule :: [Module] -> [Module]
collapseBindingGroupsModule = map $ \(Module name ds exps) -> Module name (collapseBindingGroups ds) exps
--- |
--- Replace all sets of mutually-recursive declarations with binding groups
---
createBindingGroups :: ModuleName -> [Declaration] -> Either ErrorStack [Declaration]
-createBindingGroups moduleName ds = do
- values <- parU (filter isValueDecl ds) (createBindingGroupsForValue moduleName)
- let dataDecls = filter isDataDecl ds
- allProperNames = map getProperName dataDecls
- dataVerts = map (\d -> (d, getProperName d, usedProperNames moduleName d `intersect` allProperNames)) dataDecls
- dataBindingGroupDecls <- parU (stronglyConnComp dataVerts) toDataBindingGroup
- let allIdents = map getIdent values
- valueVerts = map (\d -> (d, getIdent d, usedIdents moduleName d `intersect` allIdents)) values
- bindingGroupDecls <- parU (stronglyConnComp valueVerts) (toBindingGroup moduleName)
- return $ filter isImportDecl ds ++
- filter isExternDataDecl ds ++
- filter isExternInstanceDecl ds ++
- dataBindingGroupDecls ++
- filter isTypeClassDeclaration ds ++
- filter isFixityDecl ds ++
- filter isExternDecl ds ++
- bindingGroupDecls
-
-createBindingGroupsForValue :: ModuleName -> Declaration -> Either ErrorStack Declaration
-createBindingGroupsForValue moduleName =
- let (f, _, _) = everywhereOnValuesTopDownM return go return
- in f
+createBindingGroups moduleName = mapM f <=< handleDecls
+
where
- go (Let ds val) = Let <$> createBindingGroups moduleName ds <*> pure val
- go other = return other
+ (f, _, _) = everywhereOnValuesTopDownM return handleExprs return
+
+ handleExprs :: Expr -> Either ErrorStack Expr
+ handleExprs (Let ds val) = flip Let val <$> handleDecls ds
+ handleExprs other = return other
+
+ -- |
+ -- Replace all sets of mutually-recursive declarations with binding groups
+ --
+ handleDecls :: [Declaration] -> Either ErrorStack [Declaration]
+ handleDecls ds = do
+ let values = filter isValueDecl ds
+ dataDecls = filter isDataDecl ds
+ allProperNames = map getProperName dataDecls
+ dataVerts = map (\d -> (d, getProperName d, usedProperNames moduleName d `intersect` allProperNames)) dataDecls
+ dataBindingGroupDecls <- parU (stronglyConnComp dataVerts) toDataBindingGroup
+ let allIdents = map getIdent values
+ valueVerts = map (\d -> (d, getIdent d, usedIdents moduleName d `intersect` allIdents)) values
+ bindingGroupDecls <- parU (stronglyConnComp valueVerts) (toBindingGroup moduleName)
+ return $ filter isImportDecl ds ++
+ filter isExternDataDecl ds ++
+ filter isExternInstanceDecl ds ++
+ dataBindingGroupDecls ++
+ filter isTypeClassDeclaration ds ++
+ filter isFixityDecl ds ++
+ filter isExternDecl ds ++
+ bindingGroupDecls
-- |
-- Collapse all binding groups to individual declarations
@@ -181,7 +184,6 @@ toBindingGroup moduleName (CyclicSCC ds') =
cycleError d ds@(_:_) = rethrow (<> mkErrorStack ("The following are not yet defined here: " ++ unwords (map (show . getIdent) ds)) Nothing) $ cycleError d []
cycleError _ _ = error "Expected ValueDeclaration"
-
toDataBindingGroup :: SCC Declaration -> Either ErrorStack Declaration
toDataBindingGroup (AcyclicSCC d) = return d
toDataBindingGroup (CyclicSCC [d]) = case isTypeSynonym d of