Support for generic types
eacasanovaspedre opened this issue · comments
Enrique Alfonso Casanovas Pedre commented
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?
Dave Thomas commented
This is something that's not really been tested, feel free to add a failing test and I'll endeavour to add this.