Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/monet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ interface IMonad<T> extends Functor<T>, Bind<T>, Applicative<T> {
chain<V>(fn: (val: T) => IMonad<V>): IMonad<V>;
map<V>(fn: (val: T) => V): IMonad<V>;
join<V>(): IMonad<V>; // only if T = IMonad<V>
mapT<V1, V2>(fn: (val: V1) => V2): IMonad<IMonad<V2>>; // only if T = IMonad<V1>
mapTT<V1, V2>(fn: (val: V1) => V2): IMonad<IMonad<IMonad<V2>>>; // only if T = IMonad<IMonad<V1>>

/* These are monet-Monad-specific: */
takeLeft(m: IMonad<T>): IMonad<T>;
Expand Down
15 changes: 13 additions & 2 deletions src/monet.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
var targetType = target[TYPE_KEY] ||
target.constructor && target.constructor[TYPE_KEY]

return Boolean(targetType) &&
return Boolean(targetType) &&
targetType.length >= typeName.length &&
targetType.indexOf(typeName) === targetType.length - typeName.length
}
Expand Down Expand Up @@ -714,7 +714,7 @@
})
},
toArray: function () {
return this.map(function (val) {
return this.map(function (val) {
return [val]
}).orLazy(function () {
return []
Expand Down Expand Up @@ -1376,6 +1376,17 @@
})
}
}

type.prototype.mapT = function(fn) {
return this.map(function (ma) {
return ma.map(fn)
})
}
type.prototype.mapTT = function(fn) {
return this.map(function (ma) {
return ma.mapT(fn)
})
}
}

function addFunctorOps(type) {
Expand Down