Skip to content

Commit 2d87a91

Browse files
committed
support function holes
1 parent 16855ba commit 2d87a91

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

codeworld-server/src/Main.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ replaceHolesWithDefaultValue holes defaults input = T.unlines <$> replaceHolesIn
196196
Nothing -> Nothing
197197
Just defaultValue -> do
198198
newRest <- replaceHolesInLine xs (c + 1) (T.drop 1 rest)
199-
pure $ before <> defaultValue <> newRest
199+
pure $ before <> "(" <> defaultValue <> ")" <> newRest
200200

201201

202202
compileHandler :: CodeWorldHandler
@@ -226,12 +226,11 @@ compileHandler ctx = do
226226
Right _ -> pure (status', res')
227227
Left error -> do
228228
let errorSplit = T.splitOn "\n\n" error
229-
regex = "^program\\.hs:([[:digit:]]+):([[:digit:]]+): error:[[:cntrl:]] +[^F]+Found hole: _ :: ([[:alnum:]]+)" :: Text
229+
regex = "^program\\.hs:([[:digit:]]+):([[:digit:]]+): error:[[:cntrl:]] +[^F]+Found hole: _ :: ([[:print:]]+)[[:cntrl:]]" :: Text
230230
matches = concatMap (\block -> block =~ regex :: [[Text]]) errorSplit
231231
textToInt = read . T.unpack
232232
holes = mapMaybe (\input -> case input of { [_,line,col,ty] -> Just (textToInt line, textToInt col, ty); _ -> Nothing } ) matches
233233
replacementMap = defaultHoleValues previewConf
234-
235234

236235
case replaceHolesWithDefaultValue holes replacementMap sourceWithHoles of
237236
Nothing -> pure (status, res)

0 commit comments

Comments
 (0)