Add enum support to dhall-bash
(#873)
... as mentioned here: https://github.com/dhall-lang/dhall-haskell/issues/97#issuecomment-477699974 Similar to `dhall-json`, this translates empty alternatives to strings of the same name
This commit is contained in:
parent
e44a6e0055
commit
5c690f9ca1
|
@ -264,6 +264,10 @@ dhallToStatement expr0 var0 = go (Dhall.Core.normalize expr0)
|
|||
<> Data.ByteString.intercalate " " kvs'
|
||||
<> ")"
|
||||
return bytes
|
||||
go (Field (Union m) k) = do
|
||||
e <- first adapt (dhallToExpression (Field (Union m) k))
|
||||
let bytes = "declare -r " <> var <> "=" <> e
|
||||
return bytes
|
||||
go (Embed x) = do
|
||||
Dhall.TypeCheck.absurd x
|
||||
go (Note _ e) = do
|
||||
|
@ -353,4 +357,8 @@ dhallToExpression expr0 = go (Dhall.Core.normalize expr0)
|
|||
go (TextLit (Chunks [] a)) = do
|
||||
let bytes = Data.Text.Encoding.encodeUtf8 a
|
||||
return (Text.ShellEscape.bytes (Text.ShellEscape.bash bytes))
|
||||
go e@(Field (Union m) k) =
|
||||
case Dhall.Map.lookup k m of
|
||||
Just Nothing -> go (TextLit (Chunks [] k))
|
||||
_ -> Left (UnsupportedExpression e)
|
||||
go e = Left (UnsupportedExpression e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user