core.tmp (11037B)
1 [1 of 1] Compiling Main ( Main.hs, Main.o ) 2 3 ==================== Tidy Core ==================== 4 Result size of Tidy Core = {terms: 394, types: 238, coercions: 9} 5 6 main_$sstringReplace :: [Char] -> [Char] -> [Char] -> [Char] 7 [GblId, Arity=2, Caf=NoCafRefs, Str=DmdType <L,U><L,U>] 8 main_$sstringReplace = 9 \ (pat :: [Char]) (rep :: [Char]) -> 10 let { 11 lvl :: Bool 12 [LclId, Str=DmdType] 13 lvl = $fEq[]_$s$c== ([] @ Char) pat } in 14 let { 15 patLength [Dmd=<L,U(U)>] :: Int 16 [LclId, Str=DmdType] 17 patLength = 18 case $wlenAcc @ Char pat 0 of ww { __DEFAULT -> I# ww } } in 19 \ (eta :: [Char]) -> 20 case eta of _ [Occ=Dead] { 21 [] -> [] @ Char; 22 : y ys -> 23 case patLength of _ [Occ=Dead] { I# n# -> 24 let { 25 acc :: [Char] 26 [LclId, Str=DmdType] 27 acc = 28 letrec { 29 go [Occ=LoopBreaker] :: [Char] -> [Char] 30 [LclId, Arity=1, Str=DmdType <S,1*U>] 31 go = 32 \ (ds :: [Char]) -> 33 case ds of _ [Occ=Dead] { 34 [] -> [] @ Char; 35 : y1 ys1 -> 36 let { 37 acc1 :: [Char] 38 [LclId, Str=DmdType] 39 acc1 = go ys1 } in 40 let { 41 $j :: Void# -> [Char] 42 [LclId, Arity=1, Str=DmdType <L,A>] 43 $j = 44 \ _ [Occ=Dead] -> 45 ++ 46 @ Char 47 rep 48 (case tagToEnum# @ Bool (<# n# 0) of _ [Occ=Dead] { 49 False -> drop_drop# @ Char n# (: @ Char y1 acc1); 50 True -> : @ Char y1 acc1 51 }) } in 52 case tagToEnum# @ Bool (<=# n# 0) of _ [Occ=Dead] { 53 False -> 54 case tagToEnum# @ Bool (>=# n# 0) of _ [Occ=Dead] { 55 False -> 56 case lvl of _ [Occ=Dead] { 57 False -> : @ Char y1 acc1; 58 True -> $j void# 59 }; 60 True -> 61 case $fEq[]_$s$c== 62 (take_unsafe_UInt @ Char n# (: @ Char y1 acc1)) pat 63 of _ [Occ=Dead] { 64 False -> : @ Char y1 acc1; 65 True -> $j void# 66 } 67 }; 68 True -> 69 case lvl of _ [Occ=Dead] { 70 False -> : @ Char y1 acc1; 71 True -> $j void# 72 } 73 } 74 }; } in 75 go ys } in 76 let { 77 $j :: Void# -> [Char] 78 [LclId, Arity=1, Str=DmdType <L,A>] 79 $j = 80 \ _ [Occ=Dead] -> 81 ++ 82 @ Char 83 rep 84 (case tagToEnum# @ Bool (<# n# 0) of _ [Occ=Dead] { 85 False -> drop_drop# @ Char n# (: @ Char y acc); 86 True -> : @ Char y acc 87 }) } in 88 case tagToEnum# @ Bool (<=# n# 0) of _ [Occ=Dead] { 89 False -> 90 case tagToEnum# @ Bool (>=# n# 0) of _ [Occ=Dead] { 91 False -> 92 case lvl of _ [Occ=Dead] { 93 False -> : @ Char y acc; 94 True -> $j void# 95 }; 96 True -> 97 case $fEq[]_$s$c== 98 (take_unsafe_UInt @ Char n# (: @ Char y acc)) pat 99 of _ [Occ=Dead] { 100 False -> : @ Char y acc; 101 True -> $j void# 102 } 103 }; 104 True -> 105 case lvl of _ [Occ=Dead] { 106 False -> : @ Char y acc; 107 True -> $j void# 108 } 109 } 110 } 111 } 112 113 stringReplace :: forall a. Eq a => [a] -> [a] -> [a] -> [a] 114 [GblId, 115 Arity=3, 116 Caf=NoCafRefs, 117 Str=DmdType <L,U(C(C1(U)),A)><L,U><L,U>] 118 stringReplace = 119 \ (@ a) ($dEq :: Eq a) (pat :: [a]) (rep :: [a]) -> 120 let { 121 lvl :: Bool 122 [LclId, Str=DmdType] 123 lvl = $fEq[]_$c== @ a $dEq ([] @ a) pat } in 124 let { 125 patLength [Dmd=<L,U(U)>] :: Int 126 [LclId, Str=DmdType] 127 patLength = 128 case $wlenAcc @ a pat 0 of ww { __DEFAULT -> I# ww } } in 129 \ (eta :: [a]) -> 130 case eta of _ [Occ=Dead] { 131 [] -> [] @ a; 132 : y ys -> 133 case patLength of _ [Occ=Dead] { I# n# -> 134 let { 135 acc :: [a] 136 [LclId, Str=DmdType] 137 acc = 138 letrec { 139 go [Occ=LoopBreaker] :: [a] -> [a] 140 [LclId, Arity=1, Str=DmdType <S,1*U>] 141 go = 142 \ (ds :: [a]) -> 143 case ds of _ [Occ=Dead] { 144 [] -> [] @ a; 145 : y1 ys1 -> 146 let { 147 acc1 :: [a] 148 [LclId, Str=DmdType] 149 acc1 = go ys1 } in 150 let { 151 $j :: Void# -> [a] 152 [LclId, Arity=1, Str=DmdType <L,A>] 153 $j = 154 \ _ [Occ=Dead] -> 155 ++ 156 @ a 157 rep 158 (case tagToEnum# @ Bool (<# n# 0) of _ [Occ=Dead] { 159 False -> drop_drop# @ a n# (: @ a y1 acc1); 160 True -> : @ a y1 acc1 161 }) } in 162 case tagToEnum# @ Bool (<=# n# 0) of _ [Occ=Dead] { 163 False -> 164 case tagToEnum# @ Bool (>=# n# 0) of _ [Occ=Dead] { 165 False -> 166 case lvl of _ [Occ=Dead] { 167 False -> : @ a y1 acc1; 168 True -> $j void# 169 }; 170 True -> 171 case $fEq[]_$c== 172 @ a $dEq (take_unsafe_UInt @ a n# (: @ a y1 acc1)) pat 173 of _ [Occ=Dead] { 174 False -> : @ a y1 acc1; 175 True -> $j void# 176 } 177 }; 178 True -> 179 case lvl of _ [Occ=Dead] { 180 False -> : @ a y1 acc1; 181 True -> $j void# 182 } 183 } 184 }; } in 185 go ys } in 186 let { 187 $j :: Void# -> [a] 188 [LclId, Arity=1, Str=DmdType <L,A>] 189 $j = 190 \ _ [Occ=Dead] -> 191 ++ 192 @ a 193 rep 194 (case tagToEnum# @ Bool (<# n# 0) of _ [Occ=Dead] { 195 False -> drop_drop# @ a n# (: @ a y acc); 196 True -> : @ a y acc 197 }) } in 198 case tagToEnum# @ Bool (<=# n# 0) of _ [Occ=Dead] { 199 False -> 200 case tagToEnum# @ Bool (>=# n# 0) of _ [Occ=Dead] { 201 False -> 202 case lvl of _ [Occ=Dead] { 203 False -> : @ a y acc; 204 True -> $j void# 205 }; 206 True -> 207 case $fEq[]_$c== 208 @ a $dEq (take_unsafe_UInt @ a n# (: @ a y acc)) pat 209 of _ [Occ=Dead] { 210 False -> : @ a y acc; 211 True -> $j void# 212 } 213 }; 214 True -> 215 case lvl of _ [Occ=Dead] { 216 False -> : @ a y acc; 217 True -> $j void# 218 } 219 } 220 } 221 } 222 223 main2 :: [Char] 224 [GblId, 225 Str=DmdType, 226 Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=0, Value=False, 227 ConLike=False, WorkFree=False, Expandable=False, 228 Guidance=IF_ARGS [] 160 0}] 229 main2 = 230 unpackCString# "USAGE: ./stringReplace PATTERN REPLACEMENT STRING"# 231 232 $wa :: State# RealWorld -> (# State# RealWorld, () #) 233 [GblId, 234 Arity=1, 235 Str=DmdType <L,U>, 236 Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=1, Value=True, 237 ConLike=True, WorkFree=True, Expandable=True, 238 Guidance=IF_ARGS [0] 40 0}] 239 $wa = \ (w :: State# RealWorld) -> hPutStr2 stdout main2 True w 240 241 main1 :: State# RealWorld -> (# State# RealWorld, () #) 242 [GblId, 243 Arity=1, 244 Str=DmdType <L,U>, 245 Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=1, Value=True, 246 ConLike=True, WorkFree=True, Expandable=True, 247 Guidance=IF_ARGS [0] 190 0}] 248 main1 = 249 \ (eta :: State# RealWorld) -> 250 case getArgs1 eta of _ [Occ=Dead] { (# ipv, ipv1 #) -> 251 case ipv1 of _ [Occ=Dead] { 252 [] -> $wa ipv; 253 : pat ds -> 254 case ds of _ [Occ=Dead] { 255 [] -> $wa ipv; 256 : rep ds2 -> 257 case ds2 of _ [Occ=Dead] { 258 [] -> $wa ipv; 259 : str ds3 -> 260 hPutStr2 stdout (main_$sstringReplace pat rep str) True ipv 261 } 262 } 263 } 264 } 265 266 main :: IO () 267 [GblId, 268 Arity=1, 269 Str=DmdType <L,U>, 270 Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=0, Value=True, 271 ConLike=True, WorkFree=True, Expandable=True, 272 Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=True)}] 273 main = 274 main1 275 `cast` (Sym (NTCo:IO[0] <()>_R) 276 :: (State# RealWorld -> (# State# RealWorld, () #)) ~# IO ()) 277 278 main3 :: State# RealWorld -> (# State# RealWorld, () #) 279 [GblId, 280 Arity=1, 281 Str=DmdType <L,U>, 282 Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=1, Value=True, 283 ConLike=True, WorkFree=True, Expandable=True, 284 Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=True)}] 285 main3 = 286 \ (eta :: State# RealWorld) -> 287 runMainIO1 288 @ () 289 (main1 290 `cast` (Sym (NTCo:IO[0] <()>_R) 291 :: (State# RealWorld -> (# State# RealWorld, () #)) ~# IO ())) 292 eta 293 294 main :: IO () 295 [GblId, 296 Arity=1, 297 Str=DmdType <L,U>, 298 Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=0, Value=True, 299 ConLike=True, WorkFree=True, Expandable=True, 300 Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=True)}] 301 main = 302 main3 303 `cast` (Sym (NTCo:IO[0] <()>_R) 304 :: (State# RealWorld -> (# State# RealWorld, () #)) ~# IO ()) 305 306 307 ------ Local rules for imported ids -------- 308 "SPEC stringReplace [Char]" [ALWAYS] 309 forall ($dEq :: Eq Char). 310 stringReplace @ Char $dEq 311 = main_$sstringReplace 312 313 314 Linking stringReplace ...