Skip to content

Upgrade to PS 0.15.10, fix warnings #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Options/Applicative/Builder.purs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ subparser :: forall a. Mod CommandFields a -> Parser a
subparser m = mkParser d g rdr
where
Mod _ d g = metavar "COMMAND" `append` m
groupName /\ cmds /\ subs /\ unit = mkCommand m
groupName /\ cmds /\ subs /\ _ = mkCommand m
rdr = CmdReader groupName cmds subs

-- | Builder for an argument parser.
Expand Down
4 changes: 2 additions & 2 deletions src/Options/Applicative/Extra.purs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ hsubparser :: forall a. Mod CommandFields a -> Parser a
hsubparser m = mkParser d g rdr
where
Mod _ d g = metavar "COMMAND" `append` m
groupName /\ cmds /\ subs /\ unit = mkCommand m
groupName /\ cmds /\ subs /\ _ = mkCommand m
rdr = CmdReader groupName cmds (map add_helper <<< subs)
add_helper = over ParserInfo \pinfo -> pinfo
{ infoParser = pinfo.infoParser <**> helper}
Expand Down Expand Up @@ -299,5 +299,5 @@ parserFailure pprefs pinfo msg ctx = ParserFailure $ \progn ->

renderFailure :: ParserFailure ParserHelp -> String -> Tuple String ExitCode
renderFailure failure progn =
let h /\ exit /\ cols /\ unit = un ParserFailure failure progn
let h /\ exit /\ cols /\ _ = un ParserFailure failure progn
in Tuple (renderHelp cols h) exit
38 changes: 19 additions & 19 deletions src/Text/PrettyPrint/Leijen.purs
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,11 @@ flatAlt :: Doc -> Doc -> Doc
flatAlt = FlatAlt

flatten :: Doc -> Doc
flatten (FlatAlt x y) = y
flatten (FlatAlt _ y) = y
flatten (Cat x y) = Cat (flatten x) (flatten y)
flatten (Nest i x) = Nest i (flatten x)
flatten Line = Fail
flatten (Union x y) = flatten x
flatten (Union x _) = flatten x
flatten (Column f) = Column (flatten <<< f)
flatten (Columns f) = Columns (flatten <<< f)
flatten (Nesting f) = Nesting (flatten <<< f)
Expand Down Expand Up @@ -783,7 +783,7 @@ renderFits fits rfrac w headNode
-- k = current column
-- (ie. (k >= n) && (k - n == count of inserted characters)
best :: Int -> Int -> Docs -> LazySimpleDoc
best n k Nil = SEmpty'
best _ _ Nil = SEmpty'
best n k (Cons i d ds)
= case d of
Fail -> SFail'
Expand Down Expand Up @@ -817,12 +817,12 @@ renderFits fits rfrac w headNode

-- | @fits1@ does 1 line lookahead.
fits1 :: Int -> Int -> Int -> LazySimpleDoc -> Boolean
fits1 _ _ w x | w < 0 = false
fits1 _ _ w SFail' = false
fits1 _ _ w SEmpty' = true
fits1 p m w (SChar' c x) = fits1 p m (w - 1) (force x)
fits1 p m w (SText' l s x) = fits1 p m (w - l) (force x)
fits1 _ _ w (SLine' i x) = true
fits1 _ _ w _ | w < 0 = false
fits1 _ _ _ SFail' = false
fits1 _ _ _ SEmpty' = true
fits1 p m w (SChar' _ x) = fits1 p m (w - 1) (force x)
fits1 p m w (SText' l _ x) = fits1 p m (w - l) (force x)
fits1 _ _ _ (SLine' _ _) = true

-- | @fitsR@ has a little more lookahead: assuming that nesting roughly
-- | corresponds to syntactic depth, @fitsR@ checks that not only the current line
Expand All @@ -835,12 +835,12 @@ fits1 _ _ w (SLine' i x) = true
-- | m = minimum nesting level to fit in
-- | w = the width in which to fit the first line
fitsR :: Int -> Int -> Int -> LazySimpleDoc -> Boolean
fitsR p m w x | w < 0 = false
fitsR p m w SFail' = false
fitsR p m w SEmpty' = true
fitsR p m w (SChar' c x) = fitsR p m (w - 1) (force x)
fitsR p m w (SText' l s x) = fitsR p m (w - l) (force x)
fitsR p m w (SLine' i x) | m < i = fitsR p m (p - i) (force x)
fitsR _ _ w _ | w < 0 = false
fitsR _ _ _ SFail' = false
fitsR _ _ _ SEmpty' = true
fitsR p m w (SChar' _ x) = fitsR p m (w - 1) (force x)
fitsR p m w (SText' l _ x) = fitsR p m (w - l) (force x)
fitsR p m _ (SLine' i x) | m < i = fitsR p m (p - i) (force x)
| otherwise = true

-----------------------------------------------------------
Expand All @@ -859,7 +859,7 @@ renderCompact :: Doc -> SimpleDoc
renderCompact
= scan 0 <<< List.singleton
where
scan k List.Nil = SEmpty
scan _ List.Nil = SEmpty
scan k (d List.: ds) = case d of
Fail -> SFail
Empty -> scan k ds
Expand All @@ -868,8 +868,8 @@ renderCompact
FlatAlt x _ -> scan k (x List.: ds)
Line -> SLine 0 (scan 0 ds)
Cat x y -> scan k (x List.: y List.: ds)
Nest j x -> scan k (x List.: ds)
Union x y -> scan k (y List.: ds)
Nest _ x -> scan k (x List.: ds)
Union _ y -> scan k (y List.: ds)
Column f -> scan k (f k List.: ds)
Columns f -> scan k (f Nothing List.: ds)
Nesting f -> scan k (f 0 List.:ds)
Expand All @@ -894,7 +894,7 @@ displayS :: SimpleDoc -> String
displayS SFail = unsafeCrashWith $ "@SFail@ can not appear uncaught in a rendered @SimpleDoc@"
displayS SEmpty = ""
displayS (SChar c x) = fromCharArray [c] <> displayS x
displayS (SText l s x) = s <> displayS x
displayS (SText _ s x) = s <> displayS x
displayS (SLine i x) = "\n" <> indentation i <> displayS x

instance docShow :: Show Doc where
Expand Down
2 changes: 1 addition & 1 deletion test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ spec = describe "optparse" $ do
<*> many ( strArgument ( metavar "ARGS..." ) )
i = info p noIntersperse
result = run i ["--foo", "myfile", "-a", "-b", "-c"]
isOK $ assertResult result $ \(b /\ f /\ as /\ unit) ->
isOK $ assertResult result $ \(b /\ f /\ as /\ _) ->
conjoin [ ["-a", "-b", "-c"] === Array.fromFoldable as
, true === b
, "myfile" === f ]
Expand Down