0

I have a type

let Resource = \(a : Type) ->
  { name : Text
  , type : Text
  , properties : a
  }

and a function foo : InstanceTemplateProperties -> Properties.

I need to create a function Resource InstanceTemplateProperties -> Resource Properties.

I could write it as

\(p : Resource InstanceTemplateProperties) ->
  { name = p.name
  , type = p.type
  , properties = foo p.properties
  } : Resource Properties

but it looks really cumbersome. Is there an easier and more idiomatic way to do this?

marcosh
  • 8,780
  • 5
  • 44
  • 74

1 Answers1

1

You can use // to merge the updated properties into the original.

(\p : Resource InstanceTemplateProperties) ->
  p // {properties = foo p.properties)
Gabriella Gonzalez
  • 34,863
  • 3
  • 77
  • 135
chepner
  • 497,756
  • 71
  • 530
  • 681
  • Thanks for the edit; I obviously misremembered the operator, and I think I misread the Unicode operator for a single ASCII `/` without seeing the ASCII equivalent. – chepner Jan 14 '20 at 15:43