These are chat archives for ramda/ramda

12th
Jul 2017
Johnny Hauser
@m59peacemaker
Jul 12 2017 14:34
I have an unpopular style so it's hard to get opinions. Perhaps some of you will be sympathetic. I've been writing my DOM stuff with all functions. I'm just not able to get it perfectly the style I want. Trying to nail down the perfect API. This is my best so far:
const MyComponent = pipe(
  E.Div,
  s.display('flex')
)(map( // children to that div up there
  s.flex(1),
  [
    pipe(
       E.Img,
       E.attrs({ src: theSrc }),
       s.objectFit('cover')
     ),
     E.P('hey there')
  ]
)
I think it would be good on the brain to make it read more like an html document does (within reason), which would mean the pipe at the beginning would have to be the element constructor instead...
const MyComponent = E.Div(
  s.display('flex'),
  append([
    E.Img(
      attrs({ src: theSrc }),
      s.objectFit('cover')
    ),
    E.P(append('hey there'))
  ])
)
I like the look of that, but I don't know how I feel about the constructors having to compose the pipeline internally
Johnny Hauser
@m59peacemaker
Jul 12 2017 14:40
const MyComponent = E.Div(pipe(
  s.display('flex'),
  append([
    E.Img(pipe(
      attrs({ src: theSrc }),
      s.objectFit('cover')
    )),
    E.P(append('hey there'))
  ])
))
better than pipe first, but still ugly
Johnny Hauser
@m59peacemaker
Jul 12 2017 15:19
The second one is best to me actually
Philipp Wille
@Yord
Jul 12 2017 17:01
@mrosata late to the party, but what about:
const renameKey = (oldKey, newKey) => o(
  dissoc(oldKey),
  ap(flip(assoc(newKey)), prop(oldKey))
)
Michael Rosata
@mrosata
Jul 12 2017 18:05
@Yord that's cool. It's weird that objects can be used as applicatives. To me at least. I need to get used to it. Seems to work nice though :)
Denis Stoyanov
@xgrommx
Jul 12 2017 21:26
cata, para, ana via hylo