Skip to content

Commit

Permalink
Fix Travis jobs for GHC 8: Add fake Functor constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
fmthoma committed Dec 22, 2016
1 parent b919826 commit a8fc4fe
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Main (main) where

import Control.Concurrent.Async
import Control.Lens
import Control.Lens.Compat
import Control.Monad.Reader
import Data.Maybe
import Data.Monoid
Expand Down
30 changes: 30 additions & 0 deletions src/Control/Lens/Compat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- | In lens-4.14, the constraint @'Functor' f@ is missing from the definition
-- of 'to'. When compiling with GHC 8.0, this leads to warnings for definitions
-- like
--
-- @
-- foo :: Getter Bar Foo
-- foo = to fooFromBar
-- @
--
-- because of the redundant @'Functor' f@ constraint. This module exports an
-- alternative definition with the added @'Functor' f@ Constraint.
module Control.Lens.Compat
( to
, module Control.Lens
) where

import Control.Lens hiding (to)
import qualified Control.Lens as Lens


-- | Build an (index-preserving) 'Getter' from an arbitrary Haskell function.
--
-- Identical to "Control.Lens".'Lens.to' except for the additional constraint
-- @'Functor' f@.
to :: (Profunctor p, Functor f, Contravariant f) => (s -> a) -> Optic' p f s a
to k = fakeFunctorConstraintToDisableGhc8WarningWithLens4_14 . Lens.to k
where
fakeFunctorConstraintToDisableGhc8WarningWithLens4_14 getter =
let _ = rmap (fmap undefined) getter
in getter
2 changes: 1 addition & 1 deletion src/Vgrep/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Vgrep.Environment
, module Graphics.Vty.Prelude
) where

import Control.Lens
import Control.Lens.Compat
import Graphics.Vty.Prelude

import Vgrep.Environment.Config
Expand Down
2 changes: 1 addition & 1 deletion src/Vgrep/Environment/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE TemplateHaskell #-}
module Vgrep.Environment.Config where

import Control.Lens
import Control.Lens.Compat
import Control.Monad.IO.Class
import Data.Maybe
import Data.Monoid
Expand Down
2 changes: 1 addition & 1 deletion src/Vgrep/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Vgrep.Text (
, expandLineForDisplay
) where

import Control.Lens
import Control.Lens.Compat
import Control.Monad.Reader.Class
import Data.Char
import Data.Text (Text)
Expand Down
4 changes: 2 additions & 2 deletions src/Vgrep/Widget/HorizontalSplit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ module Vgrep.Widget.HorizontalSplit (
, rightWidgetFocused
) where

import Control.Lens
import Control.Lens.Compat
import Data.Monoid
import Graphics.Vty.Image hiding (resize)
import Graphics.Vty.Image hiding (resize)
import Graphics.Vty.Input

import Vgrep.Environment
Expand Down
4 changes: 2 additions & 2 deletions src/Vgrep/Widget/HorizontalSplit/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module Vgrep.Widget.HorizontalSplit.Internal (
, (%)
) where

import Control.Lens
import Data.Ratio ((%))
import Control.Lens.Compat
import Data.Ratio ((%))


-- $setup
Expand Down
2 changes: 1 addition & 1 deletion src/Vgrep/Widget/Pager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Vgrep.Widget.Pager (
, replaceBufferContents
) where

import Control.Lens hiding ((:<), (:>))
import Control.Lens.Compat hiding ((:<), (:>))
import Data.Foldable
import Data.Sequence (Seq, (><))
import qualified Data.Sequence as Seq
Expand Down
8 changes: 4 additions & 4 deletions src/Vgrep/Widget/Pager/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module Vgrep.Widget.Pager.Internal (
, highlighted
) where

import Control.Lens
import Data.Sequence (Seq)
import Data.Set (Set)
import Data.Text (Text)
import Control.Lens.Compat
import Data.Sequence (Seq)
import Data.Set (Set)
import Data.Text (Text)


-- | Keeps track of the lines of text to display, the current scroll
Expand Down
2 changes: 1 addition & 1 deletion src/Vgrep/Widget/Results.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Vgrep.Widget.Results (
) where

import Control.Applicative
import Control.Lens
import Control.Lens.Compat
import Control.Monad.State.Extended
import Data.Foldable
import Data.Maybe
Expand Down
2 changes: 1 addition & 1 deletion src/Vgrep/Widget/Results/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Vgrep.Widget.Results.Internal (
) where

import Control.Applicative
import Control.Lens (Getter, pre, to, _Just)
import Control.Lens.Compat (Getter, pre, to, _Just)
import Data.Foldable
import Data.Function
import Data.List (groupBy)
Expand Down
2 changes: 1 addition & 1 deletion test/Test/Case.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Test.Case (
, TestTree ()
) where

import Control.Lens
import Control.Lens.Compat
import Test.QuickCheck.Monadic
import Test.Tasty
import Test.Tasty.QuickCheck
Expand Down
2 changes: 1 addition & 1 deletion test/Test/Vgrep/Widget/Pager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
module Test.Vgrep.Widget.Pager (test) where

import Control.Lens
import Control.Lens.Compat
import qualified Data.Sequence as S
import Data.Text.Testable ()
import qualified Data.Text.Testable as T
Expand Down
2 changes: 1 addition & 1 deletion test/Test/Vgrep/Widget/Results.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE LambdaCase #-}
module Test.Vgrep.Widget.Results (test) where

import Control.Lens (Getter, over, to, view, views, _1)
import Control.Lens.Compat (Getter, over, to, view, views, _1)
import Data.Map.Strict ((!))
import qualified Data.Map.Strict as Map
import Data.Monoid ((<>))
Expand Down
1 change: 1 addition & 0 deletions vgrep.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ library
default-extensions: LambdaCase
, MultiWayIf
exposed-Modules: Control.Concurrent.STM.TPQueue
, Control.Lens.Compat
, Control.Monad.State.Extended
, Pipes.Concurrent.PQueue
, Vgrep.App
Expand Down

0 comments on commit a8fc4fe

Please sign in to comment.