Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RecordDotSyntaxのあれこれ

lotz
December 11, 2019

 RecordDotSyntaxのあれこれ

lotz

December 11, 2019
Tweet

More Decks by lotz

Other Decks in Programming

Transcript

  1. > :t (.age) (.age) :: Person -> Int > :t

    (. age) (. age) :: (Int -> c) -> Person -> c ۭനͷ༗Γແ͠Ͱ͜͜·Ͱҙຯ͕มΘΔͷ͸ ॳ৺ऀʹ͸೉͘͠ͳ͍ʁ
  2. f a.b.c x ͷύʔε f a.foo.bar.baz.quux 12 ͸ f (a.foo.bar.baz.quux)

    12 ͱධՁ͞ΕΔ ((f a).foo.bar.baz.quux) 12Ͱ͸ͳ͍ https://github.com/shayne-fletcher-da/ghc-proposals/blob/record-dot-syntax/proposals/0000-record-dot-syntax.md#record-selection
  3. Lens͸ʁ • f $ record ^. field ͕ f record.field

    ͱॻ͚Δ • Lens͸ෳࡶա͗Δ… • Lensͱ͸໊લۭ͕ؒҟͳΔͷͰҰॹʹ࢖͑Δ https://github.com/shayne-fletcher-da/ghc-proposals/blob/record-dot-syntax/proposals/0000-record-dot-syntax.md#alternatives-to-this-proposal
  4. ͜͏͍͏දه͸ແ͍ • ߋ৽ʹؔ͢Δߏจ • a{field * 2} • a{field <-

    (*2)} • a{field * = 2} • ߋ৽ʹؔ͢ΔηΫγϣϯ • ({a=}) • ({a=b}) • (.lbl=) https://github.com/shayne-fletcher-da/ghc-proposals/blob/record-dot-syntax/proposals/0000-record-dot-syntax.md#alternatives-within-this-proposal