Skip to content

Commit

Permalink
style: update gleam formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-gang committed May 30, 2024
1 parent 6f96b5b commit 63cc352
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 118 deletions.
3 changes: 1 addition & 2 deletions compiled_starters/gleam/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ version = "1.0.0"
# https://gleam.run/writing-gleam/gleam-toml/.

[dependencies]
argv = ">= 1.0.2 and < 2.0.0"
gleam_erlang = "~> 0.25"
gleam_stdlib = "~> 0.34 or ~> 1.0"
argv = ">= 1.0.2 and < 2.0.0"
file_streams = ">= 0.4.2 and < 1.0.0"

[dev-dependencies]
gleeunit = "~> 1.0"
6 changes: 2 additions & 4 deletions compiled_starters/gleam/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "file_streams", version = "0.4.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "file_streams", source = "hex", outer_checksum = "86775D2F36B74C54C64CA9080ACA9B9CF4655759E8D3E87E1A2EA9B0FA8D0804" },
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
]

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
gleam_erlang = { version = "~> 0.25" }
file_streams = { version = ">= 0.4.2 and < 1.0.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
27 changes: 13 additions & 14 deletions compiled_starters/gleam/src/grep.gleam
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import argv
import gleam/erlang
import gleam/io
import gleam/string
import gleam/erlang

pub fn main() {
// You can use print statements as follows for debugging, they'll be visible when running tests.
io.println("Logs from your program will appear here!")

// Uncomment this to pass the first stage
// let args = argv.load().arguments
// let assert Ok(input_line) = erlang.get_line("")
// case args {
// ["-E", pattern, ..] -> {
// case match_pattern(input_line, pattern) {
// True -> exit(0)
// False -> exit(1)
// }
// io.println("Success")
// ["-E", pattern, ..] -> {
// case match_pattern(input_line, pattern) {
// True -> exit(0)
// False -> exit(1)
// }
// io.println("Success")
// }
// _ -> {
// io.println("Expected first argument to be '-E'")
Expand All @@ -25,13 +24,13 @@ pub fn main() {
}

fn match_pattern(input_line: String, pattern: String) -> Bool {
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
}
}

@external(erlang, "erlang", "halt")
Expand Down
3 changes: 1 addition & 2 deletions solutions/gleam/01-cq2/code/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ version = "1.0.0"
# https://gleam.run/writing-gleam/gleam-toml/.

[dependencies]
argv = ">= 1.0.2 and < 2.0.0"
gleam_erlang = "~> 0.25"
gleam_stdlib = "~> 0.34 or ~> 1.0"
argv = ">= 1.0.2 and < 2.0.0"
file_streams = ">= 0.4.2 and < 1.0.0"

[dev-dependencies]
gleeunit = "~> 1.0"
6 changes: 2 additions & 4 deletions solutions/gleam/01-cq2/code/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "file_streams", version = "0.4.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "file_streams", source = "hex", outer_checksum = "86775D2F36B74C54C64CA9080ACA9B9CF4655759E8D3E87E1A2EA9B0FA8D0804" },
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
]

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
gleam_erlang = { version = "~> 0.25" }
file_streams = { version = ">= 0.4.2 and < 1.0.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
26 changes: 13 additions & 13 deletions solutions/gleam/01-cq2/code/src/grep.gleam
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import argv
import gleam/erlang
import gleam/io
import gleam/string
import gleam/erlang

pub fn main() {
let args = argv.load().arguments
let assert Ok(input_line) = erlang.get_line("")
case args {
["-E", pattern, ..] -> {
case match_pattern(input_line, pattern) {
True -> exit(0)
False -> exit(1)
}
io.println("Success")
["-E", pattern, ..] -> {
case match_pattern(input_line, pattern) {
True -> exit(0)
False -> exit(1)
}
io.println("Success")
}
_ -> {
io.println("Expected first argument to be '-E'")
Expand All @@ -21,13 +21,13 @@ pub fn main() {
}

fn match_pattern(input_line: String, pattern: String) -> Bool {
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
}
}

@external(erlang, "erlang", "halt")
Expand Down
41 changes: 20 additions & 21 deletions solutions/gleam/01-cq2/diff/src/grep.gleam.diff
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
@@ -1,38 +1,34 @@
@@ -1,37 +1,34 @@
import argv
import gleam/erlang
import gleam/io
import gleam/string
import gleam/erlang

pub fn main() {
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- io.println("Logs from your program will appear here!")
-
- // Uncomment this to pass the first stage
- // let args = argv.load().arguments
- // let assert Ok(input_line) = erlang.get_line("")
- // case args {
- // ["-E", pattern, ..] -> {
- // case match_pattern(input_line, pattern) {
- // True -> exit(0)
- // False -> exit(1)
- // }
- // io.println("Success")
- // ["-E", pattern, ..] -> {
- // case match_pattern(input_line, pattern) {
- // True -> exit(0)
- // False -> exit(1)
- // }
- // io.println("Success")
- // }
- // _ -> {
- // io.println("Expected first argument to be '-E'")
Expand All @@ -26,12 +25,12 @@
+ let args = argv.load().arguments
+ let assert Ok(input_line) = erlang.get_line("")
+ case args {
+ ["-E", pattern, ..] -> {
+ case match_pattern(input_line, pattern) {
+ True -> exit(0)
+ False -> exit(1)
+ }
+ io.println("Success")
+ ["-E", pattern, ..] -> {
+ case match_pattern(input_line, pattern) {
+ True -> exit(0)
+ False -> exit(1)
+ }
+ io.println("Success")
+ }
+ _ -> {
+ io.println("Expected first argument to be '-E'")
Expand All @@ -40,13 +39,13 @@
}

fn match_pattern(input_line: String, pattern: String) -> Bool {
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
}
}

@external(erlang, "erlang", "halt")
Expand Down
12 changes: 6 additions & 6 deletions solutions/gleam/01-cq2/explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Study and uncomment the relevant code:
let args = argv.load().arguments
let assert Ok(input_line) = erlang.get_line("")
case args {
["-E", pattern, ..] -> {
case match_pattern(input_line, pattern) {
True -> exit(0)
False -> exit(1)
}
io.println("Success")
["-E", pattern, ..] -> {
case match_pattern(input_line, pattern) {
True -> exit(0)
False -> exit(1)
}
io.println("Success")
}
_ -> {
io.println("Expected first argument to be '-E'")
Expand Down
3 changes: 1 addition & 2 deletions starter_templates/gleam/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ version = "1.0.0"
# https://gleam.run/writing-gleam/gleam-toml/.

[dependencies]
argv = ">= 1.0.2 and < 2.0.0"
gleam_erlang = "~> 0.25"
gleam_stdlib = "~> 0.34 or ~> 1.0"
argv = ">= 1.0.2 and < 2.0.0"
file_streams = ">= 0.4.2 and < 1.0.0"

[dev-dependencies]
gleeunit = "~> 1.0"
6 changes: 2 additions & 4 deletions starter_templates/gleam/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "file_streams", version = "0.4.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "file_streams", source = "hex", outer_checksum = "86775D2F36B74C54C64CA9080ACA9B9CF4655759E8D3E87E1A2EA9B0FA8D0804" },
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
]

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
gleam_erlang = { version = "~> 0.25" }
file_streams = { version = ">= 0.4.2 and < 1.0.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
27 changes: 13 additions & 14 deletions starter_templates/gleam/src/grep.gleam
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import argv
import gleam/erlang
import gleam/io
import gleam/string
import gleam/erlang

pub fn main() {
// You can use print statements as follows for debugging, they'll be visible when running tests.
io.println("Logs from your program will appear here!")

// Uncomment this to pass the first stage
// let args = argv.load().arguments
// let assert Ok(input_line) = erlang.get_line("")
// case args {
// ["-E", pattern, ..] -> {
// case match_pattern(input_line, pattern) {
// True -> exit(0)
// False -> exit(1)
// }
// io.println("Success")
// ["-E", pattern, ..] -> {
// case match_pattern(input_line, pattern) {
// True -> exit(0)
// False -> exit(1)
// }
// io.println("Success")
// }
// _ -> {
// io.println("Expected first argument to be '-E'")
Expand All @@ -25,13 +24,13 @@ pub fn main() {
}

fn match_pattern(input_line: String, pattern: String) -> Bool {
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
case string.length(pattern) {
1 -> string.contains(input_line, pattern)
_ -> {
io.println("Unhandled pattern: " <> pattern)
False
}
}
}

@external(erlang, "erlang", "halt")
Expand Down
32 changes: 0 additions & 32 deletions starter_templates/gleam/src/tmp.gleam

This file was deleted.

0 comments on commit 63cc352

Please sign in to comment.