summaryrefslogtreecommitdiff
path: root/ghc/compiler/hsSyn/HsSyn.lhs
diff options
context:
space:
mode:
authorsimonmar <unknown>2001-02-26 15:07:02 +0000
committersimonmar <unknown>2001-02-26 15:07:02 +0000
commit1c62b517711ac232a8024d91fd4b317a6804d28e (patch)
treedb67031e5975531610d33f96966ece31983ae2ad /ghc/compiler/hsSyn/HsSyn.lhs
parent8d0e6c63640414fda69fe77c126f10128a90a5f3 (diff)
downloadhaskell-1c62b517711ac232a8024d91fd4b317a6804d28e.tar.gz
[project @ 2001-02-26 15:06:57 by simonmar]
Implement do-style bindings on the GHCi command line. The syntax for a command-line is exactly that of a do statement, with the following meanings: - `pat <- expr' performs expr, and binds each of the variables in pat. - `let pat = expr; ...' binds each of the variables in pat, doesn't do any evaluation - `expr' behaves as `it <- expr' if expr is IO-typed, or `let it = expr' followed by `print it' otherwise.
Diffstat (limited to 'ghc/compiler/hsSyn/HsSyn.lhs')
-rw-r--r--ghc/compiler/hsSyn/HsSyn.lhs23
1 files changed, 15 insertions, 8 deletions
diff --git a/ghc/compiler/hsSyn/HsSyn.lhs b/ghc/compiler/hsSyn/HsSyn.lhs
index f2ad080c1a..c2feb2af26 100644
--- a/ghc/compiler/hsSyn/HsSyn.lhs
+++ b/ghc/compiler/hsSyn/HsSyn.lhs
@@ -19,12 +19,12 @@ module HsSyn (
module HsExpr,
module HsImpExp,
module HsLit,
- module HsMatches,
module HsPat,
module HsTypes,
Fixity, NewOrData,
- collectTopBinders, collectMonoBinders, collectLocatedMonoBinders,
+ collectHsBinders, collectLocatedHsBinders,
+ collectMonoBinders, collectLocatedMonoBinders,
hsModuleName, hsModuleImports
) where
@@ -36,7 +36,6 @@ import HsBinds
import HsExpr
import HsImpExp
import HsLit
-import HsMatches
import HsPat
import HsTypes
import BasicTypes ( Fixity, Version, NewOrData )
@@ -45,7 +44,6 @@ import BasicTypes ( Fixity, Version, NewOrData )
import Name ( NamedThing )
import Outputable
import SrcLoc ( SrcLoc )
-import Bag
import Module ( ModuleName )
\end{code}
@@ -119,10 +117,19 @@ where
it should return @[x, y, f, a, b]@ (remember, order important).
\begin{code}
-collectTopBinders :: HsBinds name (InPat name) -> Bag (name,SrcLoc)
-collectTopBinders EmptyBinds = emptyBag
-collectTopBinders (MonoBind b _ _) = listToBag (collectLocatedMonoBinders b)
-collectTopBinders (ThenBinds b1 b2) = collectTopBinders b1 `unionBags` collectTopBinders b2
+collectLocatedHsBinders :: HsBinds name (InPat name) -> [(name,SrcLoc)]
+collectLocatedHsBinders EmptyBinds = []
+collectLocatedHsBinders (MonoBind b _ _)
+ = collectLocatedMonoBinders b
+collectLocatedHsBinders (ThenBinds b1 b2)
+ = collectLocatedHsBinders b1 ++ collectLocatedHsBinders b2
+
+collectHsBinders :: HsBinds name (InPat name) -> [name]
+collectHsBinders EmptyBinds = []
+collectHsBinders (MonoBind b _ _)
+ = collectMonoBinders b
+collectHsBinders (ThenBinds b1 b2)
+ = collectHsBinders b1 ++ collectHsBinders b2
collectLocatedMonoBinders :: MonoBinds name (InPat name) -> [(name,SrcLoc)]
collectLocatedMonoBinders binds