fantasyland / daggy

Library for creating tagged constructors.
MIT License
700 stars 29 forks source link

Constructors for types with no arguments #5

Closed ccorcos closed 7 years ago

ccorcos commented 8 years ago

I want to get rid of these lines:

https://github.com/puffnfresh/daggy/blob/master/src/daggy.js#L113-L117

Otherwise you can't add a .map to Maybe.Nothing.prototype.

SimonRichardson commented 8 years ago

I think that breaks quite a few things, so will have to check. You can work around it by making the object aliases later.

const Maybe = extend(maybe, {Nothing, Some})

On Thu, 31 Mar 2016, 06:23 Chet Corcos, notifications@github.com wrote:

I want to get rid of these lines:

https://github.com/puffnfresh/daggy/blob/master/src/daggy.js#L113-L117

Otherwise you can't add a .map to Maybe.Nothing.prototype.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/puffnfresh/daggy/issues/5

anttih commented 8 years ago

I have this same issue. @SimonRichardson is extend defined somewhere?

SimonRichardson commented 8 years ago

Not that I'm aware of... Was just an idea, maybe it might be worth while adding, although you should add the prototype to the Maybe type and not each sum, then use the catamorphism to identify it.

safareli commented 7 years ago

I believe, Nothing is just a value, and if you want to define some method on it you can just define it directly instead of doing it on it's prototype

Nothing.map = (f) => Nothing

Also you can get prototype of an object like this obj.constructor.prototype

SimonRichardson commented 7 years ago

Think this is closed now by @safareli comment. Re-open if you've got questions.