Skip to content

Commit

Permalink
Tidy up a bit more (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaug123 authored Jun 1, 2024
1 parent 04ecbe6 commit adf497c
Show file tree
Hide file tree
Showing 20 changed files with 271 additions and 343 deletions.
8 changes: 4 additions & 4 deletions ConsumePlugin/GeneratedCatamorphism.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ module TreeCata =
instructions.RemoveAt (instructions.Count - 1)

match currentInstruction with
| Instruction.Process__TreeBuilder (x) ->
| Instruction.Process__TreeBuilder x ->
match x with
| TreeBuilder.Child (arg0_0) ->
instructions.Add Instruction.TreeBuilder_Child
instructions.Add (Instruction.Process__TreeBuilder arg0_0)
| TreeBuilder.Parent (arg0_0) ->
instructions.Add Instruction.TreeBuilder_Parent
instructions.Add (Instruction.Process__Tree arg0_0)
| Instruction.Process__Tree (x) ->
| Instruction.Process__Tree x ->
match x with
| Tree.Const (arg0_0, arg1_0) -> cata.Tree.Const arg0_0 arg1_0 |> treeStack.Add
| Tree.Pair (arg0_0, arg1_0, arg2_0) ->
Expand All @@ -92,13 +92,13 @@ module TreeCata =
let arg0_0 = treeStack.[treeStack.Count - 1]
treeStack.RemoveAt (treeStack.Count - 1)
cata.TreeBuilder.Parent arg0_0 |> treeBuilderStack.Add
| Instruction.Tree_Pair (arg2_0) ->
| Instruction.Tree_Pair arg2_0 ->
let arg0_0 = treeStack.[treeStack.Count - 1]
treeStack.RemoveAt (treeStack.Count - 1)
let arg1_0 = treeStack.[treeStack.Count - 1]
treeStack.RemoveAt (treeStack.Count - 1)
cata.Tree.Pair arg0_0 arg1_0 arg2_0 |> treeStack.Add
| Instruction.Tree_Sequential (arg0_0) ->
| Instruction.Tree_Sequential arg0_0 ->
let arg0_0_len = arg0_0

let arg0_0 =
Expand Down
8 changes: 4 additions & 4 deletions ConsumePlugin/GeneratedFileSystem.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module FileSystemItemCata =
instructions.RemoveAt (instructions.Count - 1)

match currentInstruction with
| Instruction.Process__FileSystemItem (x) ->
| Instruction.Process__FileSystemItem x ->
match x with
| FileSystemItem.Directory ({
Name = name
Expand Down Expand Up @@ -116,7 +116,7 @@ module GiftCata =
instructions.RemoveAt (instructions.Count - 1)

match currentInstruction with
| Instruction.Process__Gift (x) ->
| Instruction.Process__Gift x ->
match x with
| Gift.Book (arg0_0) -> cata.Gift.Book arg0_0 |> giftStack.Add
| Gift.Chocolate (arg0_0) -> cata.Gift.Chocolate arg0_0 |> giftStack.Add
Expand All @@ -129,15 +129,15 @@ module GiftCata =
| Gift.WithACard (arg0_0, message) ->
instructions.Add (Instruction.Gift_WithACard (message))
instructions.Add (Instruction.Process__Gift arg0_0)
| Instruction.Gift_Wrapped (arg1_0) ->
| Instruction.Gift_Wrapped arg1_0 ->
let arg0_0 = giftStack.[giftStack.Count - 1]
giftStack.RemoveAt (giftStack.Count - 1)
cata.Gift.Wrapped arg0_0 arg1_0 |> giftStack.Add
| Instruction.Gift_Boxed ->
let arg0_0 = giftStack.[giftStack.Count - 1]
giftStack.RemoveAt (giftStack.Count - 1)
cata.Gift.Boxed arg0_0 |> giftStack.Add
| Instruction.Gift_WithACard (message) ->
| Instruction.Gift_WithACard message ->
let arg0_0 = giftStack.[giftStack.Count - 1]
giftStack.RemoveAt (giftStack.Count - 1)
cata.Gift.WithACard arg0_0 message |> giftStack.Add
Expand Down
2 changes: 1 addition & 1 deletion ConsumePlugin/GeneratedSerde.fs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module FirstDuJsonSerializeExtension =

match input with
| FirstDu.EmptyCase -> node.Add ("type", System.Text.Json.Nodes.JsonValue.Create "emptyCase")
| FirstDu.Case1 (arg0) ->
| FirstDu.Case1 arg0 ->
node.Add ("type", System.Text.Json.Nodes.JsonValue.Create "case1")
let dataNode = System.Text.Json.Nodes.JsonObject ()
dataNode.Add ("data", System.Text.Json.Nodes.JsonValue.Create<string> arg0)
Expand Down
8 changes: 4 additions & 4 deletions ConsumePlugin/ListCata.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module MyListCata =
instructions.RemoveAt (instructions.Count - 1)

match currentInstruction with
| Instruction.Process__MyList (x) ->
| Instruction.Process__MyList x ->
match x with
| MyList.Nil -> cata.MyList.Nil |> myListStack.Add
| MyList.Cons ({
Expand All @@ -50,7 +50,7 @@ module MyListCata =
}) ->
instructions.Add (Instruction.MyList_Cons (head))
instructions.Add (Instruction.Process__MyList tail)
| Instruction.MyList_Cons (head) ->
| Instruction.MyList_Cons head ->
let tail = myListStack.[myListStack.Count - 1]
myListStack.RemoveAt (myListStack.Count - 1)
cata.MyList.Cons head tail |> myListStack.Add
Expand Down Expand Up @@ -97,13 +97,13 @@ module MyList2Cata =
instructions.RemoveAt (instructions.Count - 1)

match currentInstruction with
| Instruction.Process__MyList2 (x) ->
| Instruction.Process__MyList2 x ->
match x with
| MyList2.Nil -> cata.MyList2.Nil |> myList2Stack.Add
| MyList2.Cons (arg0_0, arg1_0) ->
instructions.Add (Instruction.MyList2_Cons (arg0_0))
instructions.Add (Instruction.Process__MyList2 arg1_0)
| Instruction.MyList2_Cons (arg0_0) ->
| Instruction.MyList2_Cons arg0_0 ->
let arg1_0 = myList2Stack.[myList2Stack.Count - 1]
myList2Stack.RemoveAt (myList2Stack.Count - 1)
cata.MyList2.Cons arg0_0 arg1_0 |> myList2Stack.Add
Expand Down
6 changes: 1 addition & 5 deletions WoofWare.Myriad.Plugins/AstHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ module internal AstHelper =
}
| _ -> failwithf "Didn't have alternating type-and-star in interface member definition: %+A" tupleType

let toFun (inputs : SynType list) (ret : SynType) : SynType =
(ret, List.rev inputs)
||> List.fold (fun ty input -> SynType.funFromDomain input ty)

/// Returns the args (where these are tuple types if curried) in order, and the return type.
let rec getType (ty : SynType) : (SynType * bool) list * SynType =
match ty with
Expand All @@ -204,7 +200,7 @@ module internal AstHelper =
| SynType.Paren (argType, _) -> getType argType, true
| _ -> getType argType, false

((toFun (List.map fst inputArgs) inputRet), hasParen) :: args, ret
((SynType.toFun (List.map fst inputArgs) inputRet), hasParen) :: args, ret
| _ -> [], ty

let private parseMember (slotSig : SynValSig) (flags : SynMemberFlags) : Choice<MemberInfo, PropertyInfo> =
Expand Down
34 changes: 17 additions & 17 deletions WoofWare.Myriad.Plugins/CataGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,12 @@ module internal CataGenerator =
unionCase.Fields
|> List.map (fun field ->
// TODO: adjust type parameters
SynField.Create field.Type
{
SynFieldData.Type = field.Type
Attrs = []
Ident = None
}
|> SynField.make
)

SynUnionCase.Create (unionCase.Name, fields)
Expand Down Expand Up @@ -1148,24 +1153,19 @@ module internal CataGenerator =
let cataRecord =
SynModuleDecl.Types ([ createCataRecord cataName recordDoc analysis ], range0)

SynModuleOrNamespace.CreateNamespace (
ns,
decls =
[
for openStatement in opens do
yield SynModuleDecl.CreateOpen openStatement
yield! cataStructures
yield cataRecord
yield
[
for openStatement in opens do
yield SynModuleDecl.CreateOpen openStatement
yield! cataStructures
yield cataRecord
yield
SynModuleDecl.CreateNestedModule (
modInfo,
[
SynModuleDecl.Types ([ createInstructionType analysis ], range0)
SynModuleDecl.CreateLet (loopFunction :: runFunctions)
]
)
SynModuleDecl.Types ([ createInstructionType analysis ], range0)
SynModuleDecl.createLets (loopFunction :: runFunctions)
]
)
|> SynModuleDecl.nestedModule modInfo
]
|> SynModuleOrNamespace.createNamespace ns

let generate (context : GeneratorContext) : Output =
let ast, _ =
Expand Down
Loading

0 comments on commit adf497c

Please sign in to comment.