Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Monads over multiple parameters #3

@SimonMeskens

Description

@SimonMeskens

@nadameu

TypeProp-esque Monad example

Okay, so I was thinking about your example code and how Haskell handles monads over types with multiple parameters and I think the solution is to use a little bit of your method and mine.

A TypeProp is an object that has a way to get a list of parameters and a way to construct a type, given parameters. This might change in the future, I have a few ideas in the pipeline that might define TypeProps differently. One thing is that this library is basically a dynamic, type-level pattern matcher. There's currently some TypeScript issues blocking it from allowing me to expose that behavior, but that might change things.

Now, here's how Haskell defines the Either monad:

instance Monad (Either e) where
    Left  l >>= _ = Left l
    Right r >>= k = k r

As you can see, it basically it creates a new TypeProp specifically for Monads, telling it how to infer parameters, like your example does. So now I'm thinking that the Monad interface's parameter shouldn't be a type, but a TypeProp. So far, so good, what's missing is a way to transform TypeProps, that is, you should be able to create a TypeProp from another TypeProp, telling it which parameters to infer and which ones to fill in.

I'll be working on this next. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions