Popularity
6.4
Declining
Activity
0.0
Stable
17
3
4

Monthly Downloads: 32
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Control     Web    
Latest version: v1.2.0.1

fused-effects-lens alternatives and similar packages

Based on the "Web" category.
Alternatively, view fused-effects-lens alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of fused-effects-lens or a related project?

Add another 'Web' Package

README

fused-effects-lens

Hackage [BSD3 license](LICENSE) Build Status

This package provides an interface to the lens library (and other such libraries such as microlens and generic-lens) that is compatible with fused-effects. The standard formulation of lens combinators for operating in MonadState contexts—use, .=, et al—rely on mtl for MonadState and MonadReader, which is not applicable to Reader and State effects.

This package is meant to be used alongside lens, like so:

import Control.Lens hiding (view, use, assign)
import Control.Effect.Lens (view, use, assign)

Example

Given a Context type that we will use in a State effect:

data Context = Context
  { _amount :: Int
  , _disabled :: Bool
  } deriving (Eq, Show)

makeLenses ''Context

We can can use the use combinators to extract a lens target from the current state, and assign to write to a field of that state:

stateTest :: (Has (State Context) sig m) => m Int
stateTest = do
  initial <- use amount
  amount .= (initial + 1)
  disabled .= True
  use amount

You can find a more complete example, including one that works with multiple State constraints in a single computation, in the test directory.

License

BSD3, like fused-effects.


*Note that all licence references and agreements mentioned in the fused-effects-lens README section above are relevant to that project's source code only.