Permalink
Browse files

Adding a proxy argument to the scale method.

This is to prevent a problem with type checking applications of
scale due to the use of possibly non-injective type functions in
the scale method.
  • Loading branch information...
kosmikus committed Jun 25, 2011
1 parent 0dddd84 commit 61d668334187cb61e4872262cac6fd05c94fbd64
Showing with 7 additions and 6 deletions.
  1. +5 −4 src/MiniApp/Particle.hs
  2. +1 −1 src/Space/Classes.hs
  3. +1 −1 src/Space/Spherical1D.hs
View
@@ -18,7 +18,7 @@ import Approx
-- | Data type for a particle moving through a space with a
-- mesh. Indexed on the mesh itself.
-data (Mesh mesh) => Particle mesh = Particle
+data Particle mesh = Particle
{
cell :: !(MeshCell mesh) -- ^ Current cell in mesh.
, location :: !(MeshSpace mesh) -- ^ Location in mesh's space.
@@ -45,9 +45,10 @@ instance (Mesh m) => P.Particle (Particle m) where
weightedEnergy :: (Mesh m) => Particle m -> Energy
weightedEnergy particle = applyWeight (weight particle) (energy particle)
-weightedMomentum :: (Space (MeshSpace m), Mesh m) => Particle m -> MomentumM m
-weightedMomentum particle = scale (direction $ location particle) $
- (engwValue $ weight particle)*(spValue $ speed particle)
+weightedMomentum :: (Mesh m) => Particle m -> MomentumM m
+weightedMomentum particle =
+ scale (location particle) (direction $ location particle) $
+ (engwValue $ weight particle) * (spValue $ speed particle)
deriving instance ( Mesh mesh
, Show (MeshSpace mesh)
View
@@ -12,7 +12,7 @@ class Space s where
stream :: s -> Distance -> s
position :: s -> Position s
direction :: s -> Direction s
- scale :: Direction s -> Double -> Velocity s
+ scale :: s -> Direction s -> Double -> Velocity s
make :: Position s -> Direction s -> s
-- | Infix operator for streaming.
View
@@ -46,6 +46,6 @@ instance Space Spherical1D where
stream (Vector2 x y) (Distance d) = Vector2 (x+d) y
position s = Radius $ vmag s
direction s = normalize s
- scale direction scalar = (normalized_value direction) |* scalar
+ scale _ direction scalar = normalized_value direction |* scalar
make (Radius pos) dir = pos *| (normalized_value dir)

0 comments on commit 61d6683

Please sign in to comment.