Skip to content

Commit

Permalink
clean up toOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyrosenbluth committed Apr 7, 2014
1 parent cf6f934 commit 0a6c286
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Diagrams/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@ styleToOutput globalToOutput normToOutput =
toOutput :: forall v. (Data v, Data (Scalar v), Num (Scalar v), Ord (Scalar v), Fractional (Scalar v))
=> Scalar v -> Scalar v -> Measure v -> Measure v
toOutput g n m =
case (g, n, m) of
(_, _, m'@(Output _)) -> m'
(_, _, (Local s)) -> Output s
(g', _, (Global s)) -> Output (g' * s)
(_, n', (Normalized s)) -> Output (n' * s * 0.01)

(g', n', (MinM m1 m2)) -> outBin min (toOutput g' n' m1) (toOutput g' n' m2)
(g', n', (MaxM m1 m2)) -> outBin max (toOutput g' n' m1) (toOutput g' n' m2)
(_ , _ , (ZeroM)) -> Output 0
(g', n', (NegateM m')) -> outUn negate (toOutput g' n' m')
(g', n', (PlusM m1 m2)) -> outBin (+) (toOutput g' n' m1) (toOutput g' n' m2)
(g', n', (ScaleM s m')) -> outUn (s*) (toOutput g' n' m')
case m of
m'@(Output _) -> m'
Local s -> Output s
Global s -> Output (g * s)
Normalized s -> Output (n * s * 0.01)

This comment has been minimized.

Copy link
@byorgey

byorgey Apr 7, 2014

Member

Also, I'm going to argue that we make Normalized relative to 1 again instead of 100. I think we are moving in a direction where idiomatic diagrams code doesn't have many (if any) explicit literal numeric values written down for measures. The cases I can think of where you would want to explicitly supply a number are of the sort where you have computed some number (rather than writing a numeric literal in your program), in which case it makes much more sense to have it be relative to 1 instead of 100.

This comment has been minimized.

Copy link
@jeffreyrosenbluth

jeffreyrosenbluth Apr 7, 2014

Author Member

That's fine with mean, I vacillate back and forth between 1 and 100 so I'm happy to be nudged in either direction.
I'll change it.

This comment has been minimized.

Copy link
@JohnLato

JohnLato via email Apr 7, 2014


MinM m1 m2 -> outBin min (toOutput g n m1) (toOutput g n m2)
MaxM m1 m2 -> outBin max (toOutput g n m1) (toOutput g n m2)
ZeroM -> Output 0
NegateM m' -> outUn negate (toOutput g n m')
PlusM m1 m2 -> outBin (+) (toOutput g n m1) (toOutput g n m2)
ScaleM s m' -> outUn (s*) (toOutput g n m')
where
outUn op (Output o1) = Output (op o1)
outUn _ _ = error "outUn: The sky is falling!"
Expand Down

0 comments on commit 0a6c286

Please sign in to comment.