
12 Nov
2010
12 Nov
'10
10:14 p.m.
On 12 November 2010 21:48, Jonathan Geddes
I cringe to imagine what the equivalent is in current Haskell syntax. Anyone want to try it? Not me!
Perhaps not pretty - but it is regular and avoids Template Haskell an manages for the few times I have records-in-records: doubleInner3OfA :: A -> A doubleInner3OfA = (\s a -> s { inner1 = f1 a }) <*> inner1 where f1 = (\s a -> s { inner2 = f2 a }) <*> inner2 f2 = (\s a -> s { inner3 = 2 * a }) <*> inner3 data A = A { inner1 :: B } deriving (Eq,Show) data B = B { inner2 :: C } deriving (Eq,Show) data C = C { inner3 :: Int } deriving (Eq,Show) t1 = A (B (C 1)) demo1 = doubleInner3OfA $ t1