[Compose] 13. Lift into a Pointed Functor with of

We examine the of function we've seen on a few types and discover it's the Pointed interface.

 

Instead of doing constructor way of Task:

const useTask= (x) => 
  new Task((rej,  res) => res(x))

 

We can just say:

Task.of("something"); //Task("something")
Either.of("something"); // Either("something");
Box.of(100); // Box(100)

 

posted @ 2016-12-19 16:50  Zhentiw  阅读(208)  评论(0编辑  收藏  举报