Skip to content

Commit

Permalink
trim context during pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
darky committed Jun 25, 2024
1 parent 21fbc8f commit fb5595d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ glance = ">= 0.11.0"
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
gleamyshell = ">= 1.0.0"
glexer = ">= 1.0.1 and < 2.0.0"
gluple = ">= 2.0.0"
gluple = ">= 2.2.0"
simplifile = ">= 1.7.0"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages = [
{ name = "gleamyshell", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleamyshell", source = "hex", outer_checksum = "48FEEDD643B6381817222D94DB94BD3803C4B3575911B73A8C8C96620F09DBCF" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "glexer", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "BD477AD657C2B637FEF75F2405FAEFFA533F277A74EF1A5E17B55B1178C228FB" },
{ name = "gluple", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gluple", source = "hex", outer_checksum = "914CE96C09D55CF72B657DFFF10302D2038276125CC1F78656BCF4BBC4291A58" },
{ name = "gluple", version = "2.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gluple", source = "hex", outer_checksum = "7D61583F17EFBF26043C14A417FF56D1BC709A45F75BB499E35CA28C9C3A8EB9" },
{ name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
]

Expand All @@ -21,5 +21,5 @@ gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleamyshell = { version = ">= 1.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
glexer = { version = ">= 1.0.1 and < 2.0.0" }
gluple = { version = ">= 2.0.0" }
gluple = { version = ">= 2.2.0" }
simplifile = { version = ">= 1.7.0" }
23 changes: 13 additions & 10 deletions src/glerd.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import gleamyshell
import glexer.{type Position, Position}
import glexer/token.{CommentDoc, UpperName}
import gluple/addition as ga
import gluple/removal as gr
import simplifile

type FilePath {
Expand Down Expand Up @@ -65,7 +66,15 @@ pub fn generate(root) {
#(file_path, content |> FileContent)
})
|> iterator.map(fn(ctx) {
use _, file_content <- ga.with_append2(ctx)
use file_path, _ <- ga.with_append2(ctx)
file_path.val
|> string.replace(root <> "/", "")
|> string.replace(".gleam", "")
|> ModuleName
})
|> iterator.map(fn(ctx) { ctx |> gr.remove_first3 })
|> iterator.map(fn(ctx) {
use file_content, _ <- ga.with_append2(ctx)
file_content.val
|> glexer.new
|> glexer.lex
Expand All @@ -87,23 +96,17 @@ pub fn generate(root) {
|> MetaDict
})
|> iterator.map(fn(ctx) {
use file_path, _, _ <- ga.with_append3(ctx)
file_path.val
|> string.replace(root <> "/", "")
|> string.replace(".gleam", "")
|> ModuleName
})
|> iterator.map(fn(ctx) {
use _, file_content, _, _ <- ga.with_append4(ctx)
use file_content, _, _ <- ga.with_append3(ctx)
let assert Ok(module) = file_content.val |> glance.module
let Module(_, custom_types_definitions, ..) = module
use custom_type_definition <- list.flat_map(custom_types_definitions)
let Definition(_, custom_type) = custom_type_definition
let CustomType(_, _, _, _, variants) = custom_type
variants
})
|> iterator.map(fn(ctx) { ctx |> gr.remove_first4 })
|> iterator.map(fn(ctx) {
let #(_, _, meta_dict, module_name, variants) = ctx
let #(module_name, meta_dict, variants) = ctx
use Variant(record_name, fields) <- list.map(variants)
let fields =
fields
Expand Down

0 comments on commit fb5595d

Please sign in to comment.