Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepillabout committed May 13, 2023
1 parent b87f9e1 commit 267f8e5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion 2023-05-11-bound.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ data ExpTransF i m f a
| ExpTransFLam (m f a)
```

The `Bound` instance for `ExpTransF` then becomes [^7]:
The `Bound` instance for `ExpTransF` then becomes[^7]:

```haskell
instance
Expand All @@ -625,6 +625,26 @@ Now, we have the following isomorphisms:
- `ExpTransF IdentityT MaybeT` is isomorphic to `ExpF`.
- `FreeF (ExpTransF IdentityT MaybeT)` is isomorphic to both `FreeF ExpF` and `Exp`.

Alternatively, you can actually define `Bound` instances for `MaybeT` and
`IdentityT`, and call out to them in the implementation of the `Bound` instance
for `ExpTransF`:

```haskell
instance Bound IdentityT where
(>>>=) :: Monad h => IdentityT h a -> (a -> h b) -> IdentityT h b
(IdentityT m) >>>= f = IdentityT $ m >>= f

instance Bound MaybeT where
(>>>=) :: Monad h => MaybeT h a -> (a -> h b) -> MaybeT h b
(MaybeT m) >>>= f = MaybeT $ m >>= traverse f

instance (Bound i, Bound m) => Bound (ExpF i m) where
(>>>=) :: Monad h => ExpF i m h a -> (a -> h b) -> ExpF i m h b
ex >>>= f = case ex of
ExpFApp ida idb -> ExpFApp (ida >>>= f) (idb >>>= f)
ExpFLam l -> ExpFLam $ l >>>= f
```

## Conclusion

In practice, is this `FFree`, `Bound`, and `ExpF` approach good?
Expand Down

0 comments on commit 267f8e5

Please sign in to comment.