Skip to content

Commit

Permalink
roc format, use basic-cli 0.19.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewilliamboswell committed Jan 23, 2025
1 parent a4c2f40 commit 9cbfe2a
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 241 deletions.
5 changes: 2 additions & 3 deletions examples/http-get-json.roc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
app [main!] {
# TODO restore with basic-cli release
pf: platform "../../basic-cli/platform/main.roc",
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/bi5zubJ-_Hva9vxxPq4kNx4WHX6oFs8OP6Ad0tCYlrY.tar.br",
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases
}

Expand All @@ -11,7 +10,7 @@ import pf.Stdout
import json.Json

# HTTP GET request with easy decoding to json
main! = \_args ->
main! = |_args|

# Easy decoding/deserialization of { "foo": "something" } into a Roc var
{ foo } = Http.get!("http://localhost:8000", Json.utf8)?
Expand Down
5 changes: 2 additions & 3 deletions examples/optional.roc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
app [main!] {
# TODO restore with basic-cli release
cli: platform "../../basic-cli/platform/main.roc",
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/bi5zubJ-_Hva9vxxPq4kNx4WHX6oFs8OP6Ad0tCYlrY.tar.br",
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases
}

Expand All @@ -10,7 +9,7 @@ import json.OptionOrNull exposing [OptionOrNull]

Object : { first_name : Str, last_name : OptionOrNull Str }

main! = \_args ->
main! = |_args|
none_obj : Object
none_obj = { first_name: "Luke", last_name: OptionOrNull.none({}) }
null_obj : Object
Expand Down
5 changes: 2 additions & 3 deletions examples/simple1.roc
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
app [main!] {
# TODO restore with basic-cli release
cli: platform "../../basic-cli/platform/main.roc",
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/bi5zubJ-_Hva9vxxPq4kNx4WHX6oFs8OP6Ad0tCYlrY.tar.br",
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases
}

import cli.Stdout
import json.Json

main! = \_args ->
main! = |_args|
request_body = Str.to_utf8("{\"Image\":{\"Animated\":false,\"Height\":600,\"Ids\":[116,943,234,38793],\"Thumbnail\":{\"Height\":125,\"Url\":\"http:\\/\\/www.example.com\\/image\\/481989943\",\"Width\":100},\"Title\":\"View from 15th Floor\",\"Width\":800}}")

decoder = Json.utf8_with({ field_name_mapping: PascalCase })
Expand Down
5 changes: 2 additions & 3 deletions examples/simple2.roc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
app [main!] {
# TODO restore with basic-cli release
cli: platform "../../basic-cli/platform/main.roc",
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/bi5zubJ-_Hva9vxxPq4kNx4WHX6oFs8OP6Ad0tCYlrY.tar.br",
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases
}

import cli.Stdout
import json.Json
import "data.json" as request_body : List U8

main! = \_args ->
main! = |_args|
decoder = Json.utf8_with({})

decoded : Decode.DecodeResult (List DataRequest)
Expand Down
9 changes: 4 additions & 5 deletions examples/tuple.roc
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
app [main!] {
# TODO restore with basic-cli release
cli: platform "../../basic-cli/platform/main.roc",
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/bi5zubJ-_Hva9vxxPq4kNx4WHX6oFs8OP6Ad0tCYlrY.tar.br",
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases
}

import cli.Stdout
import json.Json

main! = \_args ->
main! = |_args|
bytes = Str.to_utf8("[ [ 123,\n\"apples\" ], [ 456, \"oranges\" ]]")

decoded : Decode.DecodeResult (List FruitCount)
Expand All @@ -20,7 +19,7 @@ main! = \_args ->
FruitCount : (U32, Str)
to_str : List FruitCount -> Str
to_str = \fcs ->
to_str = |fcs|
fcs
|> List.map(\(count, fruit) -> "${fruit}:${Num.to_str(count)}")
|> List.map(|(count, fruit)| "${fruit}:${Num.to_str(count)}")
|> Str.join_with(", ")
Loading

0 comments on commit 9cbfe2a

Please sign in to comment.