{-# OPTIONS -fno-warn-missing-signatures #-}
module Dodge.Menu.OptionType where
import Dodge.Data
import Dodge.Menu.PushPop
import Control.Lens

makeBoolOption lns t = Toggle
    (return . Just . (config . lns #%~ not)) 
    (\u -> Right (t , show (u ^# config . lns)))

makeEnumOption lns str sideeff = Toggle
    (\u -> Just <$> sideeff (u & config . lns #%~ cycleEnum) )
    (\u -> Right (str , show (u ^# config . lns)) )

makeSubmenuOption submenu t = Toggle (pushScreen submenu) (const t)

cycleEnum :: (Eq a, Enum a,Bounded a) => a -> a
cycleEnum x 
    | x == maxBound = minBound
    | otherwise = succ x
