Go to file
2023-12-27 20:26:21 +00:00
2023-12-24 12:43:01 +00:00
2023-12-27 20:26:21 +00:00
2023-05-06 15:48:36 +01:00
2023-12-27 20:26:21 +00:00
2023-12-27 11:46:12 +00:00
2023-05-06 15:48:36 +01:00
2023-05-06 15:48:36 +01:00
2023-05-06 15:48:36 +01:00
2023-05-06 15:48:36 +01:00
2023-12-24 12:43:01 +00:00
2023-12-27 11:46:12 +00:00
2023-12-24 12:43:01 +00:00
2023-05-06 15:48:36 +01:00
2023-12-27 11:46:12 +00:00
2023-12-27 11:46:12 +00:00
2023-12-27 11:46:12 +00:00

fsharp-arguments

Some helpers in Myriad which might be useful for someone writing an argument parser.

RemoveOptions

Takes a record like this:

type Foo =
    {
        A : int option
        B : string
        C : float list
    }

and stamps out a record like this:

[<RequireQualifiedAccess>]
module Foo =
    type Short =
        {
            A : int
            B : string
            C : float list
        }

(This is a proof of concept. It would be better to somehow disambiguate the module name.)

JsonParse

Takes records like this:

[<MyriadPlugin.JsonParse>]
type InnerType =
    {
        [<JsonPropertyName "something">]
        Thing : string
    }

/// My whatnot
[<MyriadPlugin.JsonParse>]
type JsonRecordType =
    {
        /// A thing!
        A : int
        /// Another thing!
        B : string
        [<System.Text.Json.Serialization.JsonPropertyName "hi">]
        C : int list
        D : InnerType
    }

and stamps out parsing methods like this:


/// Module containing JSON parsing methods for the InnerType type
[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module InnerType =
    /// Parse from a JSON node.
    let jsonParse (node: System.Text.Json.Nodes.JsonNode) : InnerType =
        let Thing = node.["something"].AsValue().GetValue<string>()
        { Thing = Thing }
namespace UsePlugin

/// Module containing JSON parsing methods for the JsonRecordType type
[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module JsonRecordType =
    /// Parse from a JSON node.
    let jsonParse (node: System.Text.Json.Nodes.JsonNode) : JsonRecordType =
        let D = InnerType.jsonParse node.["d"]

        let C =
            node.["hi"].AsArray() |> Seq.map (fun elt -> elt.GetValue<int>()) |> List.ofSeq

        let B = node.["b"].AsValue().GetValue<string>()
        let A = node.["a"].AsValue().GetValue<int>()
        { A = A; B = B; C = C; D = D }
Description
Some Myriad plugins for F#
Readme MIT 3.4 MiB
Languages
F# 99.8%
Nix 0.2%