Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generic types #115

Closed
eacasanovaspedre opened this issue Aug 17, 2021 · 1 comment
Closed

Support for generic types #115

eacasanovaspedre opened this issue Aug 17, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed probably-not

Comments

@eacasanovaspedre
Copy link

eacasanovaspedre commented Aug 17, 2021

Using Myriad I noticed that when the records have a generic type parameter the generated code does not include the type parameter, so it fails to compile.

Input code:

[<Generator.Fields "fields">]
[<Generator.Lenses("lenses")>]
type InputType<'T> = {
    Field1: int
    Field2: 'T
}

Generated:

module InputTypeLenses =
    open Myr
    let Field1 =
        (fun (x: InputType) -> x.Field1), (fun (x: InputType) (value: int) -> { x with Field1 = value })

    let Field2 =
        (fun (x: InputType) -> x.Field2), (fun (x: InputType) (value: 'T) -> { x with Field2 = value })

module InputType =
    open Myr
    let Field1 (x: InputType) = x.Field1
    let Field2 (x: InputType) = x.Field2
    let create (field1: int) (field2: 'T): InputType = { Field1 = field1; Field2 = field2 }
    let map (mapField1: int -> int) (mapField2: 'T -> 'T) (record': InputType) =
        { record' with
              Field1 = mapField1 record'.Field1
              Field2 = mapField2 record'.Field2 }

Am I missing something or is this feature missing?

@7sharp9
Copy link
Collaborator

7sharp9 commented Aug 18, 2021

This is something that's not really been tested, feel free to add a failing test and I'll endeavour to add this.

@7sharp9 7sharp9 added enhancement New feature or request vnext labels Aug 18, 2021
@7sharp9 7sharp9 added help wanted Extra attention is needed and removed vnext labels May 10, 2022
@7sharp9 7sharp9 closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed probably-not
Projects
None yet
Development

No branches or pull requests

2 participants