Add indentation to the paragraphs inserted in patterns

Ugly, but fixes #6. Ugly still better than non-valid-haskell result.
pull/35/head
Lennart Spitzner 2017-03-06 16:52:05 +01:00
parent 8d163eb099
commit cea81d5369
2 changed files with 18 additions and 10 deletions

View File

@ -702,6 +702,15 @@ showPackageDetailedInfo pkginfo =
isValidPosition position | validX && validY = Just position
| otherwise = Nothing
#test issue-6-pattern-linebreak-validity
## this is ugly, but at least syntactically valid.
foo = Reflex.runSpiderHost $ ReflexHost.hostApp $ do
(inputEvent :: Reflex.Event Reflex.Spider String, inputFire :: String
-> IO Bool ) <-
ReflexHost.newExternalEvent
liftIO . forkIO . forever $ getLine >>= inputFire
ReflexHost.performEvent_ $ fmap (liftIO . putStrLn) inputEvent
###############################################################################
###############################################################################
@ -738,11 +747,3 @@ isValidPosition position | validX && validY = Just position
## where
## role = stringProperty "WM_WINDOW_ROLE"
#test linebreak
#pending
foo = Reflex.runSpiderHost $ ReflexHost.hostApp $ do
(inputEvent :: Reflex.Event Reflex.Spider String, inputFire :: String -> IO Bool)
<- ReflexHost.newExternalEvent
liftIO . forkIO . forever $ getLine >>= inputFire
ReflexHost.performEvent_ $ fmap (liftIO . putStrLn) inputEvent

View File

@ -109,10 +109,17 @@ layoutPat lpat@(L _ pat) = docWrapNode lpat $ case pat of
case Seq.viewr patDocs of
Seq.EmptyR -> error "cannot happen ljoiuxoasdcoviuasd"
xR Seq.:> xN -> do
xN' <- docSeq
xN' <- -- at the moment, we don't support splitting patterns into
-- multiple lines. but we cannot enforce pasting everything
-- into one line either, because the type signature will ignore
-- this if we overflow sufficiently.
-- In order to prevent syntactically invalid results in such
-- cases, we need the AddBaseY here.
-- This can all change when patterns get multiline support.
docAddBaseY BrIndentRegular $ docSeq
[ appSep $ return xN
, appSep $ docLit $ Text.pack "::"
, tyDoc
, docForceSingleline $ tyDoc
]
return $ xR Seq.|> xN'
ListPat elems _ _ ->