packages feed

fresnel-fused-effects (empty) → 0.0.0.0

raw patch · 5 files changed

+173/−0 lines, 5 filesdep +basedep +fresneldep +fused-effects

Dependencies added: base, fresnel, fused-effects

Files

+ CHANGELOG.md view
@@ -0,0 +1,3 @@+# 0.0.0.0++Initial release.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2021-2022, Rob Rix++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Rob Rix nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# `fresnel-fused-effects`++A handful of operators bridging `fresnel` optics to `fused-effects` effects.
+ fresnel-fused-effects.cabal view
@@ -0,0 +1,53 @@+cabal-version:      2.4+name:               fresnel-fused-effects+version:            0.0.0.0+synopsis:           fresnel/fused-effects integration+description:        A handful of operators bridging `fresnel` optics to `fused-effects` effects.+homepage:           https://github.com/fresnel/fresnel+bug-reports:        https://github.com/fresnel/fresnel/issues+license:            BSD-3-Clause+license-file:       LICENSE+author:             Rob Rix+maintainer:         rob.rix@me.com++copyright:          2022 Rob Rix+category:           Control+extra-source-files:+  CHANGELOG.md+  README.md++common common+  default-language: Haskell2010+  ghc-options:+    -Weverything+    -Wno-all-missed-specialisations+    -Wno-implicit-prelude+    -Wno-missed-specialisations+    -Wno-missing-import-lists+    -Wno-missing-local-signatures+    -Wno-missing-safe-haskell-mode+    -Wno-monomorphism-restriction+    -Wno-name-shadowing+    -Wno-safe+    -Wno-unsafe+  if (impl(ghc >= 8.8))+    ghc-options: -Wno-missing-deriving-strategies+  if (impl(ghc >= 8.10))+    ghc-options:+      -Wno-missing-safe-haskell-mode+      -Wno-prepositive-qualified-module+  if (impl(ghc >= 9.2))+    ghc-options:+      -Wno-missing-kind-signatures++library+  import: common+  exposed-modules:+    Fresnel.Effect++  build-depends:+    , base           >= 4.14 && < 5+    , fresnel       ^>= 0+    , fused-effects ^>= 1.1+  hs-source-dirs:   src+  default-language: Haskell2010
+ src/Fresnel/Effect.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE RankNTypes #-}+module Fresnel.Effect+( -- * Access+  -- ** Reader+  view+, views+  -- ** State+, use+, uses+  -- * Assignment+, assign+, modifying+, (.=)+, (%=)+, (?=)+, (<~)+  -- ** Arithmetical+, (+=)+, (-=)+, (*=)+, (//=)+) where++import           Control.Algebra+import qualified Control.Effect.Reader as R+import qualified Control.Effect.State as S+import qualified Fresnel.Getter as O+import qualified Fresnel.Setter as O++view :: Has (R.Reader r) sig m => O.Getter r a -> m a+view o = R.asks (O.view o)++views :: Has (R.Reader r) sig m => O.Getter r a -> (a -> b) -> m b+views o f = R.asks (O.views o f)+++use :: Has (S.State s) sig m => O.Getter s a -> m a+use o = S.gets (O.view o)++uses :: Has (S.State s) sig m => O.Getter s a -> (a -> b) -> m b+uses o f = S.gets (O.views o f)+++assign, (.=) :: Has (S.State s) sig m => O.Setter s s a b -> b -> m ()++assign o v = S.modify (O.set o v)++(.=) = assign++infix 4 .=+++modifying, (%=) :: Has (S.State s) sig m => O.Setter s s a b -> (a -> b) -> m ()++modifying o f = S.modify (O.over o f)++(%=) = modifying++infix 4 %=++++(?=) :: Has (S.State s) sig m => O.Setter s s a (Maybe b) -> b -> m ()+o ?= v = o .= Just v+++infix 4 ?=+++(<~) :: Has (S.State s) sig m => O.Setter s s a b -> m b -> m ()+o <~ m = m >>= assign o++infixr 2 <~+++(+=), (-=), (*=) :: (Has (S.State s) sig m, Num a) => O.Setter s s a a -> a -> m ()+o += n = modifying o (+ n)+o -= n = modifying o (subtract n)+o *= n = modifying o (* n)++(//=) :: (Has (S.State s) sig m, Fractional a) => O.Setter s s a a -> a -> m ()+o //= n = modifying o (/ n)++infix 4 +=, -=, *=, //=