Q:

Haskell equivalent to class specialization in OOP

I'm testing some optimization techniques for rendering static voxel scenes and learning some Haskell along the way. I have voxels defined as
type Voxel = ( VoxelId, Position ). 

where VoxelId is simply an alias for Int. Since I anticipate some linear algebra down the line, I wanted Position to represent 3-dimensional vector. Library I'm using (matrix) implements only Matrix data type, but having Position have underlying type of Matrix only simplify further computations, so I'm okay with that.
However, it doesn't make much sense for Position to be anything else than 3-dimensional vector, so I'd like to constrain Position to 3x1 matrices, so when I use specifically Position in a function signature, I'm guaranteed to expect either 3x1 matrix or compilation error.
In C++ or other OO language I could do something like this:
class Matrix
{
  Matrix(int rows, int columns)
  {}
}

class Position : public Matrix
{
  Position()
  : Matrix (3, 1)
  {}
}

and use Position when I expect only 3x1 matrix and reference to Matrix everywhere else.
Let's assume Matrix from the library I'm using have a constructor function
matrix :: (rows) -> (columns) -> Matrix

How can I replicate this behavior in Haskell without redefining for Position all operations Matrix implements?

A:

In Haskell there's no subtyping like in OOP.
You can define you own data type
newtype Position = P { unP :: Matrix ... }
   deriving (Show) -- , etc.

and a smart constructor
position :: Double -> Double -> Double -> Position
position x1 x2 x3 = 
   Position (newMatrix 1 3 [[x1,x2,x3]])  -- pseudo code

If you really want to hide the internal representation, you can put the above in its own module and export only the smart constructor. Doing that however will require you to define and export all the operations you need on this Position type, otherwise it will be too opaque to be useful.
Assuming you don't hide the representation, note that Position and Matrix ... are two distinct types. So you can't pass a Position to something which wants a Matrix. So, instead of
matrixMultiply somePosition someMatrix

one needs to do
matrixMultiply (unP somePosition) someMatrix 

and get a Matrix result. If the result should be a Position instead, one can/needs to define a custom multiplication function:
posMultiply :: Position -> Matrix ... -> Position
posMultiply m _ | wrongSize m = error "matrix has the wrong size!"
posMultiply m (Position p) = Position (matrixMultiply m p)

Depending on how much static guarantees you want, this may get a bit cumbersome.
In many cases, safe coercions can soften the pain.
A simpler alternative could be to have a dumber constructor which does not use a custom type. This is a plain function
position :: Double -> Double -> Double -> Matrix ...
position x1 x2 x3 = 
   newMatrix 1 3 [[x1,x2,x3]]  -- pseudo code

