add whitespace on list comprehensions, applications etc.

text editor interprets these things as errors (e.g. unterminated qq for list comprehension) and underlines red, even though there is no real error.
This commit is contained in:
Inari Listenmaa
2024-09-09 19:38:27 +02:00
parent 981d6b9bdd
commit 1037b209ae
3 changed files with 17 additions and 17 deletions

View File

@@ -172,11 +172,11 @@ value env t0 =
ImplArg t -> (VImplArg.) # value env t ImplArg t -> (VImplArg.) # value env t
Table p res -> liftM2 VTblType # value env p <# value env res Table p res -> liftM2 VTblType # value env p <# value env res
RecType rs -> do lovs <- mapPairsM (value env) rs RecType rs -> do lovs <- mapPairsM (value env) rs
return $ \vs->VRecType $ mapSnd ($vs) lovs return $ \vs->VRecType $ mapSnd ($ vs) lovs
t@(ExtR t1 t2) -> ((extR t.)# both id) # both (value env) (t1,t2) t@(ExtR t1 t2) -> ((extR t.)# both id) # both (value env) (t1,t2)
FV ts -> ((vfv .) # sequence) # mapM (value env) ts FV ts -> ((vfv .) # sequence) # mapM (value env) ts
R as -> do lovs <- mapPairsM (value env.snd) as R as -> do lovs <- mapPairsM (value env.snd) as
return $ \ vs->VRec $ mapSnd ($vs) lovs return $ \ vs->VRec $ mapSnd ($ vs) lovs
T i cs -> valueTable env i cs T i cs -> valueTable env i cs
V ty ts -> do pvs <- paramValues env ty V ty ts -> do pvs <- paramValues env ty
((VV ty pvs .) . sequence) # mapM (value env) ts ((VV ty pvs .) . sequence) # mapM (value env) ts
@@ -376,10 +376,10 @@ valueTable env i cs =
where where
dynamic cs' ty _ = cases cs' # value env ty dynamic cs' ty _ = cases cs' # value env ty
cases cs' vty vs = err keep ($vs) (convertv cs' (vty vs)) cases cs' vty vs = err keep ($ vs) (convertv cs' (vty vs))
where where
keep msg = --trace (msg++"\n"++render (ppTerm Unqualified 0 (T i cs))) $ keep msg = --trace (msg++"\n"++render (ppTerm Unqualified 0 (T i cs))) $
VT wild (vty vs) (mapSnd ($vs) cs') VT wild (vty vs) (mapSnd ($ vs) cs')
wild = case i of TWild _ -> True; _ -> False wild = case i of TWild _ -> True; _ -> False
@@ -392,7 +392,7 @@ valueTable env i cs =
convert' cs' ((pty,vs),pvs) = convert' cs' ((pty,vs),pvs) =
do sts <- mapM (matchPattern cs') vs do sts <- mapM (matchPattern cs') vs
return $ \ vs -> VV pty pvs $ map (err bug id . valueMatch env) return $ \ vs -> VV pty pvs $ map (err bug id . valueMatch env)
(mapFst ($vs) sts) (mapFst ($ vs) sts)
valueCase (p,t) = do p' <- measurePatt # inlinePattMacro p valueCase (p,t) = do p' <- measurePatt # inlinePattMacro p
pvs <- linPattVars p' pvs <- linPattVars p'
@@ -430,19 +430,19 @@ apply' :: CompleteEnv -> Term -> [OpenValue] -> Err OpenValue
apply' env t [] = value env t apply' env t [] = value env t
apply' env t vs = apply' env t vs =
case t of case t of
QC x -> return $ \ svs -> VCApp x (map ($svs) vs) QC x -> return $ \ svs -> VCApp x (map ($ svs) vs)
{- {-
Q x@(m,f) | m==cPredef -> return $ Q x@(m,f) | m==cPredef -> return $
let constr = --trace ("predef "++show x) . let constr = --trace ("predef "++show x) .
VApp x VApp x
in \ svs -> maybe constr id (Map.lookup f predefs) in \ svs -> maybe constr id (Map.lookup f predefs)
$ map ($svs) vs $ map ($ svs) vs
| otherwise -> do r <- resource env x | otherwise -> do r <- resource env x
return $ \ svs -> vapply (gloc env) r (map ($svs) vs) return $ \ svs -> vapply (gloc env) r (map ($ svs) vs)
-} -}
App t1 t2 -> apply' env t1 . (:vs) =<< value env t2 App t1 t2 -> apply' env t1 . (:vs) =<< value env t2
_ -> do fv <- value env t _ -> do fv <- value env t
return $ \ svs -> vapply (gloc env) (fv svs) (map ($svs) vs) return $ \ svs -> vapply (gloc env) (fv svs) (map ($ svs) vs)
vapply :: GLocation -> Value -> [Value] -> Value vapply :: GLocation -> Value -> [Value] -> Value
vapply loc v [] = v vapply loc v [] = v

View File

@@ -61,11 +61,11 @@ parallelBatchCompile jobs opts rootfiles0 =
usesPresent (_,paths) = take 1 libs==["present"] usesPresent (_,paths) = take 1 libs==["present"]
where where
libs = [p|path<-paths, libs = [p | path<-paths,
let (d,p0) = splitAt n path let (d,p0) = splitAt n path
p = dropSlash p0, p = dropSlash p0,
d==lib_dir,p `elem` all_modes] d==lib_dir, p `elem` all_modes]
n = length lib_dir n = length lib_dir
all_modes = ["alltenses","present"] all_modes = ["alltenses","present"]
@@ -175,7 +175,7 @@ batchCompile1 lib_dir (opts,filepaths) =
" from being compiled." " from being compiled."
else return (maximum ts,(cnc,gr)) else return (maximum ts,(cnc,gr))
splitEither es = ([x|Left x<-es],[y|Right y<-es]) splitEither es = ([x | Left x<-es], [y | Right y<-es])
canonical path = liftIO $ D.canonicalizePath path `catch` const (return path) canonical path = liftIO $ D.canonicalizePath path `catch` const (return path)

View File

@@ -448,7 +448,7 @@ pgfMain lcs@(alc,clc) path command tpgf@(t,pgf) =
"linearizeTable" -> o =<< doLinearizeTabular pgf # tree % to "linearizeTable" -> o =<< doLinearizeTabular pgf # tree % to
"random" -> o =<< join (doRandom pgf # cat % depth % limit % to) "random" -> o =<< join (doRandom pgf # cat % depth % limit % to)
"generate" -> o =<< doGenerate pgf # cat % depth % limit % to "generate" -> o =<< doGenerate pgf # cat % depth % limit % to
"translate" -> o =<< doTranslate pgf # input % cat %to%limit%treeopts "translate" -> o =<< doTranslate pgf # input % cat % to % limit % treeopts
"translategroup" -> o =<< doTranslateGroup pgf # input % cat % to % limit "translategroup" -> o =<< doTranslateGroup pgf # input % cat % to % limit
"lookupmorpho" -> o =<< doLookupMorpho pgf # from1 % textInput "lookupmorpho" -> o =<< doLookupMorpho pgf # from1 % textInput
"grammar" -> join $ doGrammar tpgf "grammar" -> join $ doGrammar tpgf
@@ -1092,7 +1092,7 @@ linearizeTabular pgf (tos,unlex) tree =
[(to,lintab to (transfer to tree)) | to <- langs] [(to,lintab to (transfer to tree)) | to <- langs]
where where
langs = if null tos then PGF.languages pgf else tos langs = if null tos then PGF.languages pgf else tos
lintab to t = [(p,map unlex (nub [t|(p',t)<-vs,p'==p]))|p<-ps] lintab to t = [(p,map unlex (nub [t | (p',t)<-vs,p'==p])) | p<-ps]
where where
ps = nub (map fst vs) ps = nub (map fst vs)
vs = concat (PGF.tabularLinearizes pgf to t) vs = concat (PGF.tabularLinearizes pgf to t)