Skip to content

Commit

Permalink
Merge pull request #3 from fused-effects/ghc9
Browse files Browse the repository at this point in the history
GHC 9 support.
  • Loading branch information
patrickt committed Apr 7, 2021
2 parents 62c3149 + 1fa08f5 commit b363b55
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 51 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Haskell CI

on:
pull_request:
branches:
- "**"
push:
branches:
- "master"

jobs:
build:
name: ghc ${{ matrix.ghc }}
runs-on: ubuntu-16.04
strategy:
matrix:
ghc: ["8.10.4", "9.0.1"]
cabal: ["3.2"]

steps:
- uses: actions/checkout@v2
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'

- uses: haskell/actions/setup@v1.1.8
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- uses: actions/cache@v2
name: Cache ~/.cabal/packages
with:
path: ~/.cabal/packages
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages
- uses: actions/cache@v2
name: Cache ~/.cabal/store
with:
path: ~/.cabal/store
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store
- uses: actions/cache@v2
name: Cache dist-newstyle
with:
path: dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-fused-effects-dist

- name: Install dependencies
run: |
cabal v2-update
cabal v2-configure --enable-benchmarks --enable-tests --write-ghc-environment-files=always -j2
cabal v2-build --only-dependencies all
- name: Build & test
run: |
cabal v2-build
38 changes: 0 additions & 38 deletions .github/workflows/haskell.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
`fused-effects-optics` uses [PVP Versioning][1].
The changelog is available [on GitHub][2].

## 0.0.2.0

* GHC 9 support.
* Add `Control.Effect.Optics.Indexed` module.
* `eview` and `eviews` are renamed to `view` and `views`.
* Added `locally`.

## 0.0.1.0

* Initially created.
Expand Down
4 changes: 2 additions & 2 deletions fused-effects-optics.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: fused-effects-optics
version: 0.1.0.0
version: 0.2.0.0
synopsis: Bridge between the optics and fused-effects ecosystems.
description: Provides combinators for the optics-based manipulation of state and context types provided by the fused-effects library, similar to those provided by optics-extra for mtl-based monad transformers.
homepage: https://github.com/fused-effects/fused-effects-optics
Expand All @@ -27,7 +27,7 @@ library
Control.Effect.Optics.Indexed


build-depends: base >= 4.12 && < 4.15
build-depends: base >= 4.12 && < 4.16
, fused-effects >= 1 && < 1.2
, optics-core >= 0.3

Expand Down
24 changes: 13 additions & 11 deletions src/Control/Effect/Optics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

module Control.Effect.Optics
( -- * Reader operations
eview,
eviews,
Control.Effect.Optics.view,
Control.Effect.Optics.views,
locally,

-- * State operations
Expand All @@ -29,28 +29,30 @@ import Optics.Core

-- | View the target of a 'Lens', 'Iso', or 'Getter' in the current context.
--
-- This function is prefixed so as not to collide with 'Optics.Core.view'.
eview ::
-- Because functions implement 'Reader.Reader', you can use this wherever
-- you would use the @view@ function in @optics@, as well as the @gview@
-- operation in @optics-extra@.
view ::
forall r a m sig k is.
( Is k A_Getter,
Has (Reader.Reader r) sig m
) =>
Optic' k is r a ->
m a
eview l = Reader.asks (view l)
{-# INLINE eview #-}
view l = Reader.asks (Optics.Core.view l)
{-# INLINE view #-}

-- | Apply a function to the target of a 'Lens', 'Iso', or 'Getter' in the current context.
eviews ::
views ::
forall r a b m sig k is.
( Is k A_Getter,
Has (Reader.Reader r) sig m
) =>
Optic' k is r a ->
(a -> b) ->
m b
eviews l f = Reader.asks (f . view l)
{-# INLINE eviews #-}
views l f = Reader.asks (f . Optics.Core.view l)
{-# INLINE views #-}

-- | Given a monadic argument, evaluate it in a context modified by applying
-- the provided function to the target of the provided 'Setter', 'Lens', or 'Traversal'.
Expand All @@ -72,7 +74,7 @@ use ::
) =>
Optic' k is s a ->
m a
use l = State.gets (view l)
use l = State.gets (Optics.Core.view l)
{-# INLINE use #-}

-- | Apply a function to the target of a 'Lens', 'Iso', or 'Getter' in the current state.
Expand All @@ -84,7 +86,7 @@ uses ::
Optic' k is s a ->
(a -> b) ->
m b
uses l f = State.gets (f . view l)
uses l f = State.gets (f . Optics.Core.view l)
{-# INLINE uses #-}

-- | Use the target of a 'AffineTraversal' or 'AffineFold' in the current state.
Expand Down

0 comments on commit b363b55

Please sign in to comment.