lensify AppState

This commit is contained in:
Jonathan Lamothe 2024-07-18 19:06:17 -04:00
parent 696b17fae1
commit 21242ecbfa
3 changed files with 15 additions and 2 deletions

View File

@ -34,6 +34,7 @@ library
build-depends: build-depends:
base >=4.7 && <5 base >=4.7 && <5
, brick >=2.1.1 && <2.2 , brick >=2.1.1 && <2.2
, microlens-th >=0.4.3.15 && <0.5
, mtl >=2.3.1 && <2.4 , mtl >=2.3.1 && <2.4
default-language: Haskell2010 default-language: Haskell2010
@ -50,6 +51,7 @@ executable hamming
base >=4.7 && <5 base >=4.7 && <5
, brick >=2.1.1 && <2.2 , brick >=2.1.1 && <2.2
, hamming , hamming
, microlens-th >=0.4.3.15 && <0.5
, mtl >=2.3.1 && <2.4 , mtl >=2.3.1 && <2.4
default-language: Haskell2010 default-language: Haskell2010
@ -70,5 +72,6 @@ test-suite hamming-test
, brick >=2.1.1 && <2.2 , brick >=2.1.1 && <2.2
, hamming , hamming
, hspec >=2.11.9 && <2.12 , hspec >=2.11.9 && <2.12
, microlens-th >=0.4.3.15 && <0.5
, mtl >=2.3.1 && <2.4 , mtl >=2.3.1 && <2.4
default-language: Haskell2010 default-language: Haskell2010

View File

@ -21,6 +21,7 @@ description: Please see the README on GitHub at <https://github.com/gith
dependencies: dependencies:
- base >= 4.7 && < 5 - base >= 4.7 && < 5
- brick >= 2.1.1 && < 2.2 - brick >= 2.1.1 && < 2.2
- microlens-th >= 0.4.3.15 && < 0.5
- mtl >= 2.3.1 && < 2.4 - mtl >= 2.3.1 && < 2.4
ghc-options: ghc-options:

View File

@ -24,15 +24,24 @@ License along with this program. If not, see
|-} |-}
module Hamming.App.Types (AppState (..), initialState) where {-# LANGUAGE TemplateHaskell #-}
module Hamming.App.Types (
AppState (..),
hammingCode,
initialState
) where
import Data.Word (Word16) import Data.Word (Word16)
import Lens.Micro.TH (makeLenses)
-- | The main state of the application -- | The main state of the application
data AppState = AppState data AppState = AppState
{ hammingCode :: Word16 { _hammingCode :: Word16
} }
makeLenses ''AppState
-- | Initial application state -- | Initial application state
initialState :: AppState initialState :: AppState
initialState = AppState 0 initialState = AppState 0