question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The new Apply spec

See original GitHub issue

Did I take Crazy Pills?

More of a question than an actual issue. I think I may be missing something with the new Apply spec updated a wee bit ago. So I started to make updates to my project to reflect this change and it seems to me like this change is limiting the API. Just want to make sure I have this right. So an Identity used to be:

function Identity(x) {
  const map = fn => Identity(fn(x))
  const value = R.always(x)
  const ap = m => m.map(x)

  return { map, value, ap }
}

and I could “chain” it outside of a lift function as:

// data === Identity 8
const data =
  Identity(add)
    .ap(Identity(3))
    .ap(Identity(5))

// or

// data === Identity 8
const another =
  Identity(3)
    .map(add)
    .ap(Identity(5))

Never have to extract in the container and I have the option of having one of the parameters do the lifting for me through map, if I choose to.

But if I am reading the spec correct it means it all looks and feels like this now:

function Identity(x) {
...
  const ap = m => Identity(m.value()(x))
...
}

const data =
  Identity(4)
    .ap(
      Identity(5)
        .ap(Identity(add))
    )

Now am I missing how to use this? It seem like I lose the ability to “chain” and am always stuck with this composing interface. So if I am reading that right it seems that we lose the ability to choose how our flows are constructed and either have to provide our users lift functions to hide all of this away from them, or limit them to this interface.

Now I am very new at this, so I am probably missing something really cool and clever here. But I guess I have two questions:

  1. What is the value of making this change? (or why was it wrong to begin with)
  2. Is there a better way to use this outside of writing liftAN functions.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
davidchamberscommented, Sep 19, 2016

What is the value of making this change?

Consistency.

Before:

map   :: Functor f => f a        ~>   (a -> b) -> f b
ap    ::   Apply f => f (a -> b) ~>        f a -> f b
chain ::   Chain f => f a        ~> (a -> f b) -> f b

After:

map   :: Functor f => f a ~>   (a -> b) -> f b
ap    ::   Apply f => f a ~> f (a -> b) -> f b
chain ::   Chain f => f a ~> (a -> f b) -> f b
1reaction
SimonRichardsoncommented, Sep 19, 2016

There you go 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

iMac 24-inch - Technical Specifications - Apple
24-inch iMac. 4.5k Retina display. 8-core Apple M1 chip. Up to 16GB memory and 2TB of storage. See all technical specifications.
Read more >
General Application - Spec On The Job
Spec On The Job's general job application. Submit an application and it will be reviewed by one of Spec's staffing agency offices.
Read more >
SPEC - Standard Performance Evaluation Corporation
1 benchmark. The worldwide standard for measuring graphics performance based on professional applications, the SPECviewperf 2020 benchmark measures the 3D ...
Read more >
ReplicaSet - Kubernetes
To update Pods to a new spec in a controlled way, use a Deployment, as ReplicaSets do not support a rolling update directly....
Read more >
Application — Elixir v1.14.2 - HexDocs
Returns the spec for app . spec(app, key). Returns the value for key in app 's specification.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found