diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-02-14 13:04:14 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-02-14 13:04:14 +0000 |
commit | 3234a4ade7204c4206831b4c1dc4a8b23624cc6b (patch) | |
tree | dffbc59d2ae6152b0aed24e83f64a9a70e5d42ca /compiler/prelude/PrelNames.lhs | |
parent | 6571f4f110248221fb3fa0ac8e5b2584cb2c5b84 (diff) | |
download | haskell-3234a4ade7204c4206831b4c1dc4a8b23624cc6b.tar.gz |
Add OverloadedLists, allowing list syntax to be overloaded
This work was all done by
Achim Krause <achim.t.krause@gmail.com>
George Giorgidze <giorgidze@gmail.com>
Weijers Jeroen <jeroen.weijers@uni-tuebingen.de>
It allows list syntax, such as [a,b], [a..b] and so on, to be
overloaded so that it works for a variety of types.
The design is described here:
http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists
Eg. you can use it for maps, so that
[(1,"foo"), (4,"bar")] :: Map Int String
The main changes
* The ExplicitList constructor of HsExpr gets witness field
* Ditto ArithSeq constructor
* Ditto the ListPat constructor of HsPat
Everything else flows from this.
Diffstat (limited to 'compiler/prelude/PrelNames.lhs')
-rw-r--r-- | compiler/prelude/PrelNames.lhs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/compiler/prelude/PrelNames.lhs b/compiler/prelude/PrelNames.lhs index a67580a18c..19acf488e0 100644 --- a/compiler/prelude/PrelNames.lhs +++ b/compiler/prelude/PrelNames.lhs @@ -227,13 +227,19 @@ basicKnownKeyNames -- Stable pointers newStablePtrName, - -- GHC Extensions + -- GHC Extensions groupWithName, -- Strings and lists unpackCStringName, unpackCStringFoldrName, unpackCStringUtf8Name, - + + -- Overloaded lists + isListClassName, + fromListName, + fromListNName, + toListName, + -- List operations concatName, filterName, mapName, zipName, foldrName, buildName, augmentName, appendName, @@ -570,6 +576,11 @@ plus_RDR = varQual_RDR gHC_NUM (fsLit "+") fromString_RDR :: RdrName fromString_RDR = nameRdrName fromStringName +fromList_RDR, fromListN_RDR, toList_RDR :: RdrName +fromList_RDR = nameRdrName fromListName +fromListN_RDR = nameRdrName fromListNName +toList_RDR = nameRdrName toListName + compose_RDR :: RdrName compose_RDR = varQual_RDR gHC_BASE (fsLit ".") @@ -1002,6 +1013,13 @@ concatName = varQual gHC_LIST (fsLit "concat") concatIdKey filterName = varQual gHC_LIST (fsLit "filter") filterIdKey zipName = varQual gHC_LIST (fsLit "zip") zipIdKey +-- Overloaded lists +isListClassName, fromListName, fromListNName, toListName :: Name +isListClassName = clsQual gHC_EXTS (fsLit "IsList") isListClassKey +fromListName = methName gHC_EXTS (fsLit "fromList") fromListClassOpKey +fromListNName = methName gHC_EXTS (fsLit "fromListN") fromListNClassOpKey +toListName = methName gHC_EXTS (fsLit "toList") toListClassOpKey + -- Class Show showClassName :: Name showClassName = clsQual gHC_SHOW (fsLit "Show") showClassKey @@ -1743,6 +1761,12 @@ mzipIdKey = mkPreludeMiscIdUnique 196 ghciStepIoMClassOpKey :: Unique ghciStepIoMClassOpKey = mkPreludeMiscIdUnique 197 +-- Overloaded lists +isListClassKey, fromListClassOpKey, fromListNClassOpKey, toListClassOpKey :: Unique +isListClassKey = mkPreludeMiscIdUnique 198 +fromListClassOpKey = mkPreludeMiscIdUnique 199 +fromListNClassOpKey = mkPreludeMiscIdUnique 500 +toListClassOpKey = mkPreludeMiscIdUnique 501 ---------------- Template Haskell ------------------- -- USES IdUniques 200-499 |