EG
Size: a a a
EG
p
SP
EG
_
, если не хочешь, чтобы её использовалиSP
SP
SP
p
p
p
DS
data MyObject = MyObject { value :: Int, textValue:: Text }
deriving stock (Show, Generic)
innerMethod :: MyObject -> Int -> IO ()
innerMethod obj arg = do
putStrLn "My object has:"
putStrLn $ "Int value + arg: " <> obj ^. #value . to (+ arg) . to show
putStrLn $ "Text value: " <> obj ^. #textValue . to undefined
method :: Int -> Getter MyObject (IO ())
method arg = to (`innerMethod` 1)
workingWithObject :: IO ()
workingWithObject = do
let myObj = MyObject 1 "123"
myObj ^. method 123
let myObj = myObj & #value .~ 2 & #textValue .~ "Other text"
myObj ^. method 456
DS
DS
EG
default
это семантически @classmethod
SP
DS
KR
KR
KR
EG