File tree Expand file tree Collapse file tree 1 file changed +15
-18
lines changed
Expand file tree Collapse file tree 1 file changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -39,47 +39,44 @@ t1 :: Quantity Length FunExpr
3939t1 = (Const 5 :+ Const 2 :* Id ) # length
4040
4141-- eller kortare
42- type CQ d = Quantity d FunExpr
42+ type QC d = Quantity d FunExpr
4343
44- t2 :: CQ Length
44+ t2 :: QC Length
4545t2 = t1
4646
4747-- Ett flygplan i turbulens
48- t3 :: CQ Length
48+ t3 :: QC Length
4949t3 = 5 + sin Id # length
5050
5151-- Ett flygplan som står stilla
52- t4 :: CQ Length
52+ t4 :: QC Length
5353t4 = 8 # length
5454
5555type Area = Length `Mul ` Length
5656
5757-- Någon slags multiplikation
58- t5 :: CQ Area
58+ t5 :: QC Area
5959t5 = t1 *# t3
6060
61- t6 :: CQ Area
61+ t6 :: QC Area
6262t6 = fmap simplify t5
6363
6464-- Någon slags division
65- t7 :: CQ Length
65+ t7 :: QC Length
6666t7 = t6 /# t4
6767
6868-- Går ej, vilket är bra
69- -- t8 :: CQ Area
69+ -- t8 :: QC Area
7070-- t8 = t6 /# t4
7171
72- -- Stöd för derivering. Hela CQ och dessa
72+ -- Stöd för derivering. Hela QC och dessa
7373-- bör vara dola för utomstående användare.
74- -- Inuti är "otypat". Wrap och unwrap borde vara "protected" och inte "public", Java analogi.
75-
76- differentiateWRTtime :: CQ d -> CQ (d `Div ` Time )
77- differentiateWRTtime cq = newWithNewQuantity
78- where
79- originalWithQuantity = cq
80- newWithQuantity = fmap derive cq
81- newWithoutQuantity = unwrap newWithQuantity
82- newWithNewQuantity = wrap newWithoutQuantity (originalWithQuantity /# time)
74+
75+ -- fmap på Quantity, men inte QC!
76+
77+ differentiateWRTtime :: QC d -> QC (d `Div ` Time )
78+ differentiateWRTtime qc = fmap simplify $ fmap derive qc /# time
79+
8380
8481
8582
You can’t perform that action at this time.
0 commit comments