Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify non-zippy applicatives like []? #3

Open
johannes-riecken opened this issue Mar 19, 2023 · 1 comment
Open

How to specify non-zippy applicatives like []? #3

johannes-riecken opened this issue Mar 19, 2023 · 1 comment

Comments

@johannes-riecken
Copy link

I'm having trouble understanding how I'd specify the instances for data types that are free monads, where applicative operations result in cartesian products of their arguments. Examples would be the list type [] or also the main data type from algebraic-graphs, which is a bit more interesting for having multiple sums:

data Graph a = Empty | Vertex a | Overlay (Graph a) (Graph a) | Connect (Graph a) (Graph a)

This data type is isomorphic to

type Graph' = FreeT
    {- f -} (Product Identity Identity)
    {- m -} (FreeT
        {- f -} (Product Identity Identity)
        {- m -} (MaybeT Identity))

and has an equivalent Applicative instance.

@Icelandjack
Copy link
Owner

You might be interested in https://www.reddit.com/r/haskell/comments/wyg656/can_the_free_monad_be_deconstructed_as_the_sum_of/, it's likely not possible without adding new features to the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants