Skip to content

Commit

Permalink
Polish default rendering of Pine values in Elm Explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Oct 1, 2024
1 parent e8fc830 commit 8082500
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,31 @@ buildPineExpressionSyntax config expression =
printValueSyntax : Pine.Value -> List String
printValueSyntax literal =
case literal of
Pine.ListValue listValues ->
case listValues of
Pine.ListValue itemsValues ->
case itemsValues of
[] ->
[ "Pine.ListValue []" ]

firstListItem :: otherListItems ->
case Pine.stringFromValue literal of
Ok asString ->
[ "Pine.valueFromString " ++ "\"" ++ asString ++ "\"" ]

Err _ ->
let
genericList () =
"Pine.ListValue"
:: (("[ " ++ String.join "\n" (printValueSyntax firstListItem))
:: List.map (printValueSyntax >> String.join "\n" >> (++) ", ") otherListItems
++ [ "]" ]
|> List.map indentString
)
in
if otherListItems == [] then
genericList ()

else
case Pine.stringFromValue literal of
Ok asString ->
[ "Pine.valueFromString " ++ "\"" ++ asString ++ "\"" ]

Err _ ->
genericList ()

Pine.BlobValue blob ->
case Pine.bigIntFromBlobValue blob of
Expand Down

0 comments on commit 8082500

Please sign in to comment.