implemented rungL
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user