dhall-bash 1.0.17 → 1.0.18
raw patch · 2 files changed
+73/−13 lines, 2 filesdep ~dhallPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dhall
API changes (from Hackage documentation)
Files
- dhall-bash.cabal +2/−2
- src/Dhall/Bash.hs +71/−11
dhall-bash.cabal view
@@ -1,5 +1,5 @@ Name: dhall-bash-Version: 1.0.17+Version: 1.0.18 Cabal-Version: >=1.8.0.2 Build-Type: Simple Tested-With: GHC == 7.10.2, GHC == 8.0.1@@ -31,7 +31,7 @@ base >= 4.8.0.0 && < 5 , bytestring < 0.11, containers < 0.7 ,- dhall >= 1.18.0 && < 1.20,+ dhall >= 1.18.0 && < 1.21, neat-interpolation < 0.4 , shell-escape < 0.3 , text >= 0.2 && < 1.3
src/Dhall/Bash.hs view
@@ -40,7 +40,7 @@ embedded anywhere Bash expressions are valid, such as the right-hand side of an assignment statement: -> $ FOO=$(dhall-to-bash <<< 'List/length Integer [1, 2, 3]')+> $ FOO=$(dhall-to-bash <<< 'List/length Natural [1, 2, 3]') > $ echo "${FOO}" > 3 @@ -55,13 +55,13 @@ if you add the @--declare@ flag specifying which variable to set or unset. For example: -> $ dhall-to-bash --declare FOO <<< '[] : Optional Integer'+> $ dhall-to-bash --declare FOO <<< 'None Natural' > unset FOO-> $ dhall-to-bash --declare FOO <<< '[1] : Optional Integer'+> $ dhall-to-bash --declare FOO <<< 'Some 1' > declare -r -i FOO=1-> $ dhall-to-bash --declare FOO <<< '[[1] : Optional Integer] : Optional (Optional Integer)'+> $ dhall-to-bash --declare FOO <<< 'Some (Some 1)' > declare -r -i FOO=1-> $ dhall-to-bash --declare FOO <<< '[[] : Optional Integer] : Optional (Optional Integer)'+> $ dhall-to-bash --declare FOO <<< 'Some (None Natural)' > unset FOO > $ dhall-to-bash --declare FOO <<< '[1, 2, 3]' > declare -r -a FOO=(1 2 3)@@ -187,7 +187,7 @@ txt = Dhall.Core.pretty e tip = case e of- OptionalLit _ _ -> "\n\n" <> [NeatInterpolation.text|+ Some _ -> "\n\n" <> [NeatInterpolation.text| Tip: You can convert an ❰Optional❱ value to a Bash statement using the --declare flag |]@@ -248,10 +248,8 @@ <> Data.ByteString.intercalate " " (Data.Foldable.toList bs') <> ")" return bytes- go (OptionalLit _ bs) = do- case bs of- Nothing -> return ("unset " <> var)- Just b -> go b+ go (Some b) = go b+ go (App None _) = return ("unset " <> var) go (RecordLit a) = do let process (k, v) = do v' <- dhallToExpression v@@ -266,7 +264,69 @@ <> Data.ByteString.intercalate " " kvs' <> ")" return bytes- go e = Left (UnsupportedStatement e)+ go (Embed x) = do+ Dhall.TypeCheck.absurd x+ go (Note _ e) = do+ go e++ -- Use an exhaustive pattern match here so that we don't forget to handle+ -- new constructors added to the API+ go e@(Const {}) = Left (UnsupportedStatement e)+ go e@(Var {}) = Left (UnsupportedStatement e)+ go e@(Lam {}) = Left (UnsupportedStatement e)+ go e@(Pi {}) = Left (UnsupportedStatement e)+ go e@(App {}) = Left (UnsupportedStatement e)+ go e@(Let {}) = Left (UnsupportedStatement e)+ go e@(Annot {}) = Left (UnsupportedStatement e)+ go e@(Bool {}) = Left (UnsupportedStatement e)+ go e@(BoolAnd {}) = Left (UnsupportedStatement e)+ go e@(BoolOr {}) = Left (UnsupportedStatement e)+ go e@(BoolEQ {}) = Left (UnsupportedStatement e)+ go e@(BoolNE {}) = Left (UnsupportedStatement e)+ go e@(BoolIf {}) = Left (UnsupportedStatement e)+ go e@(Natural ) = Left (UnsupportedStatement e)+ go e@(NaturalFold ) = Left (UnsupportedStatement e)+ go e@(NaturalBuild ) = Left (UnsupportedStatement e)+ go e@(NaturalIsZero ) = Left (UnsupportedStatement e)+ go e@(NaturalEven ) = Left (UnsupportedStatement e)+ go e@(NaturalOdd ) = Left (UnsupportedStatement e)+ go e@(NaturalToInteger) = Left (UnsupportedStatement e)+ go e@(NaturalShow ) = Left (UnsupportedStatement e)+ go e@(NaturalPlus {}) = Left (UnsupportedStatement e)+ go e@(NaturalTimes {}) = Left (UnsupportedStatement e)+ go e@(Integer ) = Left (UnsupportedStatement e)+ go e@(IntegerShow ) = Left (UnsupportedStatement e)+ go e@(IntegerToDouble ) = Left (UnsupportedStatement e)+ go e@(Double ) = Left (UnsupportedStatement e)+ go e@(DoubleLit {}) = Left (UnsupportedStatement e)+ go e@(DoubleShow ) = Left (UnsupportedStatement e)+ go e@(Text ) = Left (UnsupportedStatement e)+ go e@(TextAppend {}) = Left (UnsupportedStatement e)+ go e@(List ) = Left (UnsupportedStatement e)+ go e@(ListAppend {}) = Left (UnsupportedStatement e)+ go e@(ListBuild ) = Left (UnsupportedStatement e)+ go e@(ListFold ) = Left (UnsupportedStatement e)+ go e@(ListLength ) = Left (UnsupportedStatement e)+ go e@(ListHead ) = Left (UnsupportedStatement e)+ go e@(ListLast ) = Left (UnsupportedStatement e)+ go e@(ListIndexed ) = Left (UnsupportedStatement e)+ go e@(ListReverse ) = Left (UnsupportedStatement e)+ go e@(Optional ) = Left (UnsupportedStatement e)+ go e@(OptionalLit {}) = Left (UnsupportedStatement e)+ go e@(None ) = Left (UnsupportedStatement e)+ go e@(OptionalFold ) = Left (UnsupportedStatement e)+ go e@(OptionalBuild ) = Left (UnsupportedStatement e)+ go e@(Record {}) = Left (UnsupportedStatement e)+ go e@(Union {}) = Left (UnsupportedStatement e)+ go e@(UnionLit {}) = Left (UnsupportedStatement e)+ go e@(Combine {}) = Left (UnsupportedStatement e)+ go e@(CombineTypes {}) = Left (UnsupportedStatement e)+ go e@(Prefer {}) = Left (UnsupportedStatement e)+ go e@(Merge {}) = Left (UnsupportedStatement e)+ go e@(Constructors {}) = Left (UnsupportedStatement e)+ go e@(Field {}) = Left (UnsupportedStatement e)+ go e@(Project {}) = Left (UnsupportedStatement e)+ go e@(ImportAlt {}) = Left (UnsupportedStatement e) {-| Compile a Dhall expression to a Bash expression