Copyright | (c) Justin Le 2019 |
---|---|

License | BSD3 |

Maintainer | justin@jle.im |

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

Language | Haskell2010 |

Working with non-standard typeclasses like `Plus`

, `Apply`

, `Bind`

, and
`Pointed`

will sometimes cause problems when using with libraries that
do not provide instances, even though their types already are instances
of `Alternative`

or `Applicative`

or `Monad`

.

This module provides unsafe methods to "promote" `Applicative`

instances
to `Apply`

, `Alternative`

to `Plus`

, etc.

They are unsafe in the sense that if those types *already* have those
instances, this will cause overlapping instances errors or problems with
coherence. Because of this, you should always use these with *specific*
`f`

s, and never in a polymorphic way over `f`

.

## Synopsis

- unsafePlus :: forall f proxy r. Alternative f => proxy f -> (Plus f => r) -> r
- unsafeApply :: forall f proxy r. Applicative f => proxy f -> (Apply f => r) -> r
- unsafeBind :: forall f proxy r. Monad f => proxy f -> (Bind f => r) -> r
- unsafePointed :: forall f proxy r. Applicative f => proxy f -> (Pointed f => r) -> r

# Documentation

unsafePlus :: forall f proxy r. Alternative f => proxy f -> (Plus f => r) -> r Source #

For any

, produce a value that would require `Alternative`

f

.`Plus`

f

Always use with concrete and specific `f`

only, and never use with any
`f`

that already has a `Plus`

instance.

See documentation for `upgradeC`

for example
usages.

The `Proxy`

argument allows you to specify which specific `f`

you want to enhance. You can pass in something like

.`Proxy`

@MyFunctor

unsafeApply :: forall f proxy r. Applicative f => proxy f -> (Apply f => r) -> r Source #

For any

, produce a value that would require `Applicative`

f

.`Apply`

f

Always use with concrete and specific `f`

only, and never use with any
`f`

that already has a `Apply`

instance.

See documentation for `upgradeC`

for example
usages.

The `Proxy`

argument allows you to specify which specific `f`

you want to enhance. You can pass in something like

.`Proxy`

@MyFunctor

unsafeBind :: forall f proxy r. Monad f => proxy f -> (Bind f => r) -> r Source #

For any

, produce a value that would require `Monad`

f

.`Bind`

f

Always use with concrete and specific `f`

only, and never use with any
`f`

that already has a `Bind`

instance.

See documentation for `upgradeC`

for example
usages.

The `Proxy`

argument allows you to specify which specific `f`

you want to enhance. You can pass in something like

.`Proxy`

@MyFunctor

unsafePointed :: forall f proxy r. Applicative f => proxy f -> (Pointed f => r) -> r Source #

For any

, produce a value that would require
`Applicative`

f

.`Pointed`

f

Always use with concrete and specific `f`

only, and never use with any
`f`

that already has a `Pointed`

instance.

See documentation for `upgradeC`

for example
usages.

`Proxy`

argument allows you to specify which specific `f`

you want to enhance. You can pass in something like

.`Proxy`

@MyFunctor