implemented rungL

This commit is contained in:
2024-08-21 16:08:21 -04:00
parent e52bee47c3
commit f02aa25bb9
4 changed files with 56 additions and 1 deletions

View File

@@ -24,6 +24,8 @@ License along with this program. If not, see
-}
{-# LANGUAGE RankNTypes #-}
module Abacus (
Abacus,
newAbacus,
@@ -31,9 +33,12 @@ module Abacus (
getNumRungs,
getRung,
setRung,
rungL,
) where
import Data.List (find)
import Data.Maybe (fromJust)
import Lens.Micro.Platform (Lens', lens)
import Abacus.Internal
@@ -91,4 +96,13 @@ setRung r v a = a
| v > getNumBeads a = getNumBeads a
| otherwise = v
-- | Lens for a specific rung of an "Abacus"
rungL
:: Int
-- ^ The rung number
-> Lens' Abacus Int
rungL n = lens
(fromJust . getRung n)
(flip $ setRung n)
--jl