Skip to content

Commit 72ce9f6

Browse files
committed
PictureToSpans: implement lenses manually to avoid template haskell which has trouble on Windows and GHC 9.2 (fixes #271)
1 parent 3de781a commit 72ce9f6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/Graphics/Vty/PictureToSpans.hs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{-# LANGUAGE ExistentialQuantification #-}
44
{-# LANGUAGE NamedFieldPuns #-}
55
{-# LANGUAGE RankNTypes #-}
6-
{-# LANGUAGE TemplateHaskell #-}
76

87
-- | Transforms an image into rows of operations.
98
module Graphics.Vty.PictureToSpans
@@ -19,7 +18,6 @@ import Graphics.Vty.Span
1918

2019
import Lens.Micro
2120
import Lens.Micro.Mtl
22-
import Lens.Micro.TH
2321
import Control.Monad
2422
import Control.Monad.Reader
2523
import Control.Monad.State.Strict hiding ( state )
@@ -55,14 +53,34 @@ data BlitState = BlitState
5553
, _remainingRows :: Int
5654
}
5755

58-
makeLenses ''BlitState
56+
columnOffset :: Lens' BlitState Int
57+
columnOffset = lens _columnOffset (\e v -> e { _columnOffset = v })
58+
59+
rowOffset :: Lens' BlitState Int
60+
rowOffset = lens _rowOffset (\e v -> e { _rowOffset = v })
61+
62+
skipColumns :: Lens' BlitState Int
63+
skipColumns = lens _skipColumns (\e v -> e { _skipColumns = v })
64+
65+
skipRows :: Lens' BlitState Int
66+
skipRows = lens _skipRows (\e v -> e { _skipRows = v })
67+
68+
remainingColumns :: Lens' BlitState Int
69+
remainingColumns = lens _remainingColumns (\e v -> e { _remainingColumns = v })
70+
71+
remainingRows :: Lens' BlitState Int
72+
remainingRows = lens _remainingRows (\e v -> e { _remainingRows = v })
5973

6074
data BlitEnv s = BlitEnv
6175
{ _region :: DisplayRegion
6276
, _mrowOps :: MRowOps s
6377
}
6478

65-
makeLenses ''BlitEnv
79+
region :: Lens' (BlitEnv s) DisplayRegion
80+
region = lens _region (\e r -> e { _region = r })
81+
82+
mrowOps :: Lens' (BlitEnv s) (MRowOps s)
83+
mrowOps = lens _mrowOps (\e r -> e { _mrowOps = r })
6684

6785
type BlitM s a = ReaderT (BlitEnv s) (StateT BlitState (ST s)) a
6886

vty.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ library
4747
deepseq >= 1.1 && < 1.6,
4848
microlens < 0.4.14,
4949
microlens-mtl,
50-
microlens-th,
5150
mtl >= 1.1.1.0 && < 2.4,
5251
stm,
5352
text >= 0.11.3,

0 commit comments

Comments
 (0)