added brick scaffolding
This commit is contained in:
parent
8f6acc6b6b
commit
6f106c2660
|
@ -21,7 +21,12 @@ License along with this program. If not, see
|
||||||
|
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Brick.Main (defaultMain)
|
||||||
|
import Control.Monad (void)
|
||||||
|
|
||||||
|
import Hamming.App
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = return ()
|
main = void $ defaultMain mainApp initialState
|
||||||
|
|
||||||
--jl
|
--jl
|
||||||
|
|
|
@ -22,6 +22,8 @@ extra-source-files:
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Hamming
|
Hamming
|
||||||
|
Hamming.App
|
||||||
|
Hamming.App.Types
|
||||||
other-modules:
|
other-modules:
|
||||||
Paths_hamming
|
Paths_hamming
|
||||||
autogen-modules:
|
autogen-modules:
|
||||||
|
@ -31,6 +33,8 @@ library
|
||||||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
|
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
|
, brick >=2.1.1 && <2.2
|
||||||
|
, mtl >=2.3.1 && <2.4
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
executable hamming
|
executable hamming
|
||||||
|
@ -44,7 +48,9 @@ executable hamming
|
||||||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
|
, brick >=2.1.1 && <2.2
|
||||||
, hamming
|
, hamming
|
||||||
|
, mtl >=2.3.1 && <2.4
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
test-suite hamming-test
|
test-suite hamming-test
|
||||||
|
@ -61,6 +67,8 @@ test-suite hamming-test
|
||||||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
|
, brick >=2.1.1 && <2.2
|
||||||
, hamming
|
, hamming
|
||||||
, hspec >=2.11.9 && <2.12
|
, hspec >=2.11.9 && <2.12
|
||||||
|
, mtl >=2.3.1 && <2.4
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
|
@ -20,6 +20,8 @@ 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
|
||||||
|
- mtl >= 2.3.1 && < 2.4
|
||||||
|
|
||||||
ghc-options:
|
ghc-options:
|
||||||
- -Wall
|
- -Wall
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
{-|
|
||||||
|
|
||||||
|
Module : Hamming.App
|
||||||
|
Description : Utilities for working with Hamming codes
|
||||||
|
Copyright : (C) Jonathan Lamothe
|
||||||
|
License : AGPL-3.0-or-later
|
||||||
|
Maintainer : jonathan@jlamothe.net
|
||||||
|
Stability : experimental
|
||||||
|
Portability : POSIX
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public
|
||||||
|
License along with this program. If not, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|-}
|
||||||
|
|
||||||
|
module Hamming.App (mainApp, initialState) where
|
||||||
|
|
||||||
|
import Brick.AttrMap (forceAttrMap)
|
||||||
|
import Brick.Main (App (..), neverShowCursor)
|
||||||
|
import Brick.Util (style)
|
||||||
|
import Control.Monad.State.Class (gets)
|
||||||
|
|
||||||
|
import Hamming.App.Types
|
||||||
|
|
||||||
|
mainApp :: App AppState () ()
|
||||||
|
mainApp = App
|
||||||
|
{ appDraw = \s -> drawFunc (router s) s
|
||||||
|
, appChooseCursor = neverShowCursor
|
||||||
|
, appHandleEvent = \e -> gets router >>= flip eventHandler e
|
||||||
|
, appStartEvent = return ()
|
||||||
|
, appAttrMap = const $ forceAttrMap $ style 0
|
||||||
|
}
|
||||||
|
|
||||||
|
router :: AppState -> Route
|
||||||
|
router = undefined
|
||||||
|
|
||||||
|
--jl
|
|
@ -0,0 +1,48 @@
|
||||||
|
{-|
|
||||||
|
|
||||||
|
Module : Hamming.App.Types
|
||||||
|
Description : Utilities for working with Hamming codes
|
||||||
|
Copyright : (C) Jonathan Lamothe
|
||||||
|
License : AGPL-3.0-or-later
|
||||||
|
Maintainer : jonathan@jlamothe.net
|
||||||
|
Stability : experimental
|
||||||
|
Portability : POSIX
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public
|
||||||
|
License along with this program. If not, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|-}
|
||||||
|
|
||||||
|
module Hamming.App.Types (AppState (..), Route (..), initialState) where
|
||||||
|
|
||||||
|
import Brick.Types (BrickEvent, EventM, Widget)
|
||||||
|
import Data.Word (Word16)
|
||||||
|
|
||||||
|
-- | The main state of the application
|
||||||
|
data AppState = AppState
|
||||||
|
{ hammingCode :: Word16
|
||||||
|
}
|
||||||
|
|
||||||
|
-- | Returns appropriate draw function and event handler for the
|
||||||
|
-- current application state
|
||||||
|
data Route = Route
|
||||||
|
{ drawFunc :: AppState -> [Widget ()]
|
||||||
|
, eventHandler :: BrickEvent () () -> EventM () AppState ()
|
||||||
|
}
|
||||||
|
|
||||||
|
-- | Initial application state
|
||||||
|
initialState :: AppState
|
||||||
|
initialState = AppState 0
|
||||||
|
|
||||||
|
--jl
|
Loading…
Reference in New Issue
Block a user