added haddock comments and default menu return value

This commit is contained in:
Jonathan Lamothe 2019-08-21 00:50:22 -04:00
parent 314b41b90b
commit 8f0bd22f90
2 changed files with 11 additions and 3 deletions

View File

@ -28,6 +28,7 @@ module Mtlstats.Types.Menu (
-- * Lenses -- * Lenses
-- ** Menu Lenses -- ** Menu Lenses
menuTitle, menuTitle,
menuDefault,
menuItems, menuItems,
-- ** MenuItem Lenses -- ** MenuItem Lenses
miKey, miKey,
@ -45,14 +46,21 @@ import Mtlstats.Types
-- | Defines a menu -- | Defines a menu
data Menu a = Menu data Menu a = Menu
{ _menuTitle :: String { _menuTitle :: String
-- ^ The menu title
, _menuDefault :: a
-- ^ The default value
, _menuItems :: [MenuItem a] , _menuItems :: [MenuItem a]
-- ^ The list of items in the menu
} }
-- | Defines a menu item -- | Defines a menu item
data MenuItem a = MenuItem data MenuItem a = MenuItem
{ _miKey :: Char { _miKey :: Char
-- ^ The key that selects the menu item
, _miDescription :: String , _miDescription :: String
-- ^ The description of the menu item
, _miAction :: StateT ProgState C.Curses a , _miAction :: StateT ProgState C.Curses a
-- ^ The action to be performed when selected
} }
makeLenses ''Menu makeLenses ''Menu

View File

@ -36,7 +36,7 @@ menuSpec = describe "Menu"
showSpec :: Spec showSpec :: Spec
showSpec = describe "show" $ showSpec = describe "show" $
it "should display correctly" $ let it "should display correctly" $ let
menu = Menu "Foo" menu = Menu "Foo" ()
[ MenuItem '1' "Item 1" $ return () [ MenuItem '1' "Item 1" $ return ()
, MenuItem '2' "Item 2" $ return () , MenuItem '2' "Item 2" $ return ()
] ]