3 ms·
I deny that the return function is required to act on arbitrary data types. In Haskell, is the type [Integer] no longer a monad because it only can contain inte
by jes5199 14y ago
I deny that the return function is required to act on arbitrary data types. In Haskell, is the type [Integer] no longer a monad because it only can contain integers?
- nbouscal 14y agoYes, in Haskell the type [Integer] is not a monad. For a type to be an instance of the Monad type class, it must be of kind * -> * . As [Integer] is of kind * , it cannot possibly be an instance of Monad.
- jes5199 14y agoI didn't mean to suggest that [Integer] was of type Monad, I meant that when you write code in terms of the List monad, that code still works and is still valid and is still "monadic" even when the input to that code is a list of a non-polymorphic type.
- nbouscal 14y agoI really don't follow what you're trying to say here. >>= has signature m a -> (a -> m b) -> m b, so clearly you are working with a concrete type m a. The point is that the concrete type isn't what instantiates the Monad type class, the constructor m is.
- frio 14y agoThe distinction is: return [Integer] will give you [[Integer]] (if you're inside the list Monad). $($("#some-id")) will give you the same result as $("#some-id"), because $ of a $ doesn't nest (or make sense, really). Therefore jQuery doesn't satisfy the Monad laws :).