Skip to content

Commit

Permalink
PictureToSpans: implement lenses manually to avoid template haskell w…
Browse files Browse the repository at this point in the history
…hich has trouble on Windows and GHC 9.2 (fixes #271)
  • Loading branch information
jtdaugherty committed Jan 21, 2024
1 parent 3de781a commit 72ce9f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
26 changes: 22 additions & 4 deletions src/Graphics/Vty/PictureToSpans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}

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

import Lens.Micro
import Lens.Micro.Mtl
import Lens.Micro.TH
import Control.Monad
import Control.Monad.Reader
import Control.Monad.State.Strict hiding ( state )
Expand Down Expand Up @@ -55,14 +53,34 @@ data BlitState = BlitState
, _remainingRows :: Int
}

makeLenses ''BlitState
columnOffset :: Lens' BlitState Int
columnOffset = lens _columnOffset (\e v -> e { _columnOffset = v })

rowOffset :: Lens' BlitState Int
rowOffset = lens _rowOffset (\e v -> e { _rowOffset = v })

skipColumns :: Lens' BlitState Int
skipColumns = lens _skipColumns (\e v -> e { _skipColumns = v })

skipRows :: Lens' BlitState Int
skipRows = lens _skipRows (\e v -> e { _skipRows = v })

remainingColumns :: Lens' BlitState Int
remainingColumns = lens _remainingColumns (\e v -> e { _remainingColumns = v })

remainingRows :: Lens' BlitState Int
remainingRows = lens _remainingRows (\e v -> e { _remainingRows = v })

data BlitEnv s = BlitEnv
{ _region :: DisplayRegion
, _mrowOps :: MRowOps s
}

makeLenses ''BlitEnv
region :: Lens' (BlitEnv s) DisplayRegion
region = lens _region (\e r -> e { _region = r })

mrowOps :: Lens' (BlitEnv s) (MRowOps s)
mrowOps = lens _mrowOps (\e r -> e { _mrowOps = r })

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

Expand Down
1 change: 0 additions & 1 deletion vty.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ library
deepseq >= 1.1 && < 1.6,
microlens < 0.4.14,
microlens-mtl,
microlens-th,
mtl >= 1.1.1.0 && < 2.4,
stm,
text >= 0.11.3,
Expand Down

0 comments on commit 72ce9f6

Please sign in to comment.