[racket] [typed racket] typing monads
On 10/20/2011 01:27 PM, Jay McCarthy wrote:
> On Thu, Oct 20, 2011 at 12:52 PM, Eric Tanter<etanter at dcc.uchile.cl> wrote:
>> Thanks Sam,
>>
>> Actually, that's not what we're after.
>>
>> In untyped Racket, we have a struct monad:
>>
>> (struct monad
>> (;; A -> M A
>> return
>> ;; A -> (A -> M B) -> M B
>> bind))
>>
>> Then we have several instantiations (exception, state, what-have-you):
>> (define my-fancy-monad (monad (lambda ...) (lambda ...)))
>
> How do you protect against combing the Maybe monad's bind with the
> State monad's bind? Monads are more like objects where the methods
> have to take the same kind of thing, not just some higher level monad
> class.
I expect that's what the M type constructor is for.
It looks like Eric's monad struct is just a reification of the Haskell
type class dictionary for a monad instance (type).
Eric, is your question whether Typed Racket can parameterize a typed
structure of a type constructor rather than a type?
Ryan