summaryrefslogtreecommitdiff
path: root/compiler/utils/Util.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2016-10-08 10:06:01 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2016-10-08 10:07:14 +0100
commite660f4bf546e90fb6719ad268ca3daaecdce4b82 (patch)
tree7c23ed1a6983d951c8950f8105d3889914619d81 /compiler/utils/Util.hs
parent46b78e604c06c8878e436fea93729158dcf55269 (diff)
downloadhaskell-e660f4bf546e90fb6719ad268ca3daaecdce4b82.tar.gz
Rework renaming of children in export lists.
The target of this patch is exports such as: ``` module Foo ( T(A, B, C) ) where ``` Essentially this patch makes sure that we use the correct lookup functions in order to lookup the names in parent-children export lists. This change highlighted the complexity of this small part of GHC which accounts for the scale. This change was motivated by wanting to remove the `PatternSynonym` constructor from `Parent`. As with all these things, it quickly spiraled out of control into a much larger refactor. Reviewers: simonpj, goldfire, bgamari, austin Subscribers: adamgundry, thomie Differential Revision: https://phabricator.haskell.org/D2179 GHC Trac Issues: #11970
Diffstat (limited to 'compiler/utils/Util.hs')
-rw-r--r--compiler/utils/Util.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs
index 687ced2f47..5f66b53171 100644
--- a/compiler/utils/Util.hs
+++ b/compiler/utils/Util.hs
@@ -56,7 +56,7 @@ module Util (
-- * List operations controlled by another list
takeList, dropList, splitAtList, split,
- dropTail,
+ dropTail, capitalise,
-- * For loop
nTimes,
@@ -147,7 +147,7 @@ import System.IO.Error as IO ( isDoesNotExistError )
import System.Directory ( doesDirectoryExist, getModificationTime )
import System.FilePath
-import Data.Char ( isUpper, isAlphaNum, isSpace, chr, ord, isDigit )
+import Data.Char ( isUpper, isAlphaNum, isSpace, chr, ord, isDigit, toUpper)
import Data.Int
import Data.Ratio ( (%) )
import Data.Ord ( comparing )
@@ -720,6 +720,12 @@ split c s = case rest of
_:rest -> chunk : split c rest
where (chunk, rest) = break (==c) s
+-- | Convert a word to title case by capitalising the first letter
+capitalise :: String -> String
+capitalise [] = []
+capitalise (c:cs) = toUpper c : cs
+
+
{-
************************************************************************
* *