Skip to content

Extend the Expression type with a constructor for unescaped literals #9

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions hs/Language/Bash/PrettyPrinter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ instance PP FileDescriptor where
pp (FileDescriptor w) = (word . pack . show) w
instance (Annotation t) => PP (Expression t) where
pp (Literal lit) = word (Esc.bytes lit)
pp (UnescapedLiteral u) = word u
pp Asterisk = word "*"
pp QuestionMark = word "?"
pp Tilde = word "~"
Expand Down
4 changes: 3 additions & 1 deletion hs/Language/Bash/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ instance Foldable Statement where
well as eval and process substitution. It is 'Foldable' and a 'Functor'.
-}
data Expression t = Literal Esc.Bash
| UnescapedLiteral ByteString
| Asterisk
| QuestionMark
| Tilde
Expand Down Expand Up @@ -177,6 +178,7 @@ instance IsString (Expression t) where
instance Functor Expression where
fmap f expr = case expr of
Literal esc -> Literal esc
UnescapedLiteral u -> UnescapedLiteral u
Asterisk -> Asterisk
QuestionMark -> QuestionMark
Tilde -> Tilde
Expand All @@ -200,6 +202,7 @@ instance Functor Expression where
instance Foldable Expression where
foldMap f expr = case expr of
Literal _ -> mempty
UnescapedLiteral _ -> mempty
Asterisk -> mempty
QuestionMark -> mempty
Tilde -> mempty
Expand Down Expand Up @@ -457,4 +460,3 @@ instance Foldable Assignment where
where
f' = foldMap f
foldMapPair (x, y) = f' x `mappend` f' y

1 change: 1 addition & 0 deletions hs/bash.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ library
Language.Bash.Annotations
Language.Bash.Lib

ghc-options: -Wincomplete-patterns