mokus0 / splines

B-Splines, other splines, and NURBS in Haskell.
21 stars 5 forks source link

Scalar constraints in NURBS #3

Open fryguybob opened 11 years ago

fryguybob commented 11 years ago

You could avoid the Scalar v ~ Scalar (Scalar v) constraints by having a type below BSpline that takes the scalar type as a parameter. Something like:

data BSpline' v t s = Spline
    { degree        :: !Int
    , knotVector    :: Knots s
    , controlPoints :: v t
    }

type BSpline v t = BSpline' v t (Scalar t)

newtype NURBS v = NURBS (BSpline' V.Vector (Scalar v, v) (Scalar v))
mokus0 commented 11 years ago

I don't think I have time to look too closely at this right now, but I like the idea. One additional suggestion would be to insert the 'source' parameter as the second one, so 'BSpline v' would be a somewhat arrow-like type. I'm not sure if there are any nice properties that it would satisfy, but if it happened to it would be more likely to fit into the relevant type class that way.