Skip to content

Commit c14f8b5

Browse files
committed
Qualified import of Data.Array in generated code
1 parent ebf21a9 commit c14f8b5

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

data/AlexTemplate.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ alexIndexInt16OffAddr (AlexA# arr) off =
5858
(indexInt16OffAddr# arr off)
5959
#endif
6060
#else
61-
alexIndexInt16OffAddr arr off = arr ! off
61+
alexIndexInt16OffAddr = (Data.Array.!)
6262
#endif
6363

6464
#ifdef ALEX_GHC
@@ -83,14 +83,14 @@ alexIndexInt32OffAddr (AlexA# arr) off =
8383
(indexInt32OffAddr# arr off)
8484
#endif
8585
#else
86-
alexIndexInt32OffAddr arr off = arr ! off
86+
alexIndexInt32OffAddr = (Data.Array.!)
8787
#endif
8888

8989
#ifdef ALEX_GHC
9090
-- GHC >= 503, unsafeAt is available from Data.Array.Base.
9191
quickIndex = unsafeAt
9292
#else
93-
quickIndex arr i = arr ! i
93+
quickIndex = (Data.Array.!)
9494
#endif
9595

9696
-- -----------------------------------------------------------------------------
@@ -131,7 +131,7 @@ alexScanUser user__ input__ IBOX(sc)
131131
#ifdef ALEX_DEBUG
132132
Debug.Trace.trace ("Accept.") $
133133
#endif
134-
AlexToken input__''' len (alex_actions ! k)
134+
AlexToken input__''' len ((Data.Array.!) alex_actions k)
135135

136136

137137
-- Push the input through the DFA, remembering the most recent accepting
@@ -218,7 +218,7 @@ alexPrevCharIs c _ input__ _ _ = c == alexInputPrevChar input__
218218
alexPrevCharMatches f _ input__ _ _ = f (alexInputPrevChar input__)
219219

220220
--alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _
221-
alexPrevCharIsOneOf arr _ input__ _ _ = arr ! alexInputPrevChar input__
221+
alexPrevCharIsOneOf arr _ input__ _ _ = arr Data.Array.! alexInputPrevChar input__
222222

223223
--alexRightContext :: Int -> AlexAccPred _
224224
alexRightContext IBOX(sc) user__ _ _ input__ =

src/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ importsToInject _ cli = unlines $
400400
always_imports :: [String]
401401
always_imports =
402402
[ "#include \"ghcconfig.h\""
403-
, "import Data.Array"
403+
, "import qualified Data.Array"
404404
]
405405

406406
import_glaexts :: [String]

src/Output.hs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ outputDFA target _ _ scheme dfa
7373
. str " \"" . str (hex_chars ints) . str "\"#\n"
7474

7575
_ ->
76-
str nm . str " :: Array Int Int\n"
76+
str nm . str " :: Data.Array.Array Int Int\n"
7777
. str nm . str " = "
78-
. formatArray "listArray" upper_bound (map shows ints)
78+
. formatArray "Data.Array.listArray" upper_bound (map shows ints)
7979
. nl
8080

8181
outputAccept :: ShowS
@@ -84,7 +84,7 @@ outputDFA target _ _ scheme dfa
8484
-- see: https://github.com/simonmar/alex/issues/98
8585
-- str accept_nm . str " :: Array Int (AlexAcc " . str userStateTy . str ")\n"
8686
str accept_nm . str " = "
87-
. formatArray "listArray" n_states (snd (mapAccumR outputAccs 0 accept))
87+
. formatArray "Data.Array.listArray" n_states (snd (mapAccumR outputAccs 0 accept))
8888
. nl
8989

9090
gscanActionType res =
@@ -95,63 +95,63 @@ outputDFA target _ _ scheme dfa
9595
where
9696
(nacts, acts) = mapAccumR outputActs 0 accept
9797
actionsArray :: ShowS
98-
actionsArray = formatArray "array" nacts (concat acts)
98+
actionsArray = formatArray "Data.Array.array" nacts (concat acts)
9999
body :: ShowS
100100
body = str actions_nm . str " = " . actionsArray . nl
101101
signature :: ShowS
102102
signature = case scheme of
103103
Default { defaultTypeInfo = Just (Nothing, actionty) } ->
104-
str actions_nm . str " :: Array Int (" . str actionty . str ")\n"
104+
str actions_nm . str " :: Data.Array.Array Int (" . str actionty . str ")\n"
105105
Default { defaultTypeInfo = Just (Just tyclasses, actionty) } ->
106106
str actions_nm . str " :: (" . str tyclasses
107-
. str ") => Array Int (" . str actionty . str ")\n"
107+
. str ") => Data.Array.Array Int (" . str actionty . str ")\n"
108108
GScan { gscanTypeInfo = Just (Nothing, toktype) } ->
109-
str actions_nm . str " :: Array Int ("
109+
str actions_nm . str " :: Data.Array.Array Int ("
110110
. gscanActionType toktype . str ")\n"
111111
GScan { gscanTypeInfo = Just (Just tyclasses, toktype) } ->
112112
str actions_nm . str " :: (" . str tyclasses
113-
. str ") => Array Int ("
113+
. str ") => Data.Array.Array Int ("
114114
. gscanActionType toktype . str ")\n"
115115
Basic { basicStrType = strty,
116116
basicTypeInfo = Just (Nothing, toktype) } ->
117-
str actions_nm . str " :: Array Int ("
117+
str actions_nm . str " :: Data.Array.Array Int ("
118118
. str (show strty) . str " -> " . str toktype
119119
. str ")\n"
120120
Basic { basicStrType = strty,
121121
basicTypeInfo = Just (Just tyclasses, toktype) } ->
122122
str actions_nm . str " :: (" . str tyclasses
123-
. str ") => Array Int ("
123+
. str ") => Data.Array.Array Int ("
124124
. str (show strty) . str " -> " . str toktype
125125
. str ")\n"
126126
Posn { posnStrType = strty,
127127
posnTypeInfo = Just (Nothing, toktype) } ->
128-
str actions_nm . str " :: Array Int (AlexPosn -> "
128+
str actions_nm . str " :: Data.Array.Array Int (AlexPosn -> "
129129
. str (show strty) . str " -> " . str toktype
130130
. str ")\n"
131131
Posn { posnStrType = strty,
132132
posnTypeInfo = Just (Just tyclasses, toktype) } ->
133133
str actions_nm . str " :: (" . str tyclasses
134-
. str ") => Array Int (AlexPosn -> "
134+
. str ") => Data.Array.Array Int (AlexPosn -> "
135135
. str (show strty) . str " -> " . str toktype
136136
. str ")\n"
137137
Monad { monadStrType = strty,
138138
monadTypeInfo = Just (Nothing, toktype) } ->
139139
let
140140
actintty = if strty == Lazy then "Int64" else "Int"
141141
in
142-
str actions_nm . str " :: Array Int (AlexInput -> "
142+
str actions_nm . str " :: Data.Array.Array Int (AlexInput -> "
143143
. str actintty . str " -> Alex(" . str toktype . str "))\n"
144144
Monad { monadStrType = strty,
145145
monadTypeInfo = Just (Just tyclasses, toktype) } ->
146146
let
147147
actintty = if strty == Lazy then "Int64" else "Int"
148148
in
149149
str actions_nm . str " :: (" . str tyclasses
150-
. str ") => Array Int (AlexInput -> "
150+
. str ") => Data.Array.Array Int (AlexInput -> "
151151
. str actintty . str " -> Alex(" . str toktype . str "))\n"
152152
_ ->
153153
-- No type signature: we don't know what the type of the actions is.
154-
-- str accept_nm . str " :: Array Int (Accept Code)\n"
154+
-- str accept_nm . str " :: Data.Array.Array Int (Accept Code)\n"
155155
id
156156

157157

@@ -323,7 +323,7 @@ outputDFA target _ _ scheme dfa
323323
= str code
324324

325325
-- outputArr arr
326-
-- = str "array " . shows (bounds arr) . space
326+
-- = str "Data.Array.array " . shows (bounds arr) . space
327327
-- . shows (assocs arr)
328328

329329
-- -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)