| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
KneadShape
- type Size = Int64
- type Dim0 = ()
- type Dim1 = Size
- type Dim2 = Shape2 Size
- type Ix2 = Index2 Size
- data Vec2 tag i = Vec2 {
- vertical :: i
- horizontal :: i
- data ShapeTag
- data IndexTag
- type Shape2 = Vec2 ShapeTag
- type Index2 = Vec2 IndexTag
- squareShape :: n -> Vec2 tag n
- castToElemPtr :: Ptr (Vec2 tag a) -> Ptr a
- unzipShape :: T (Vec2 tag n) -> Vec2 tag (T n)
- zipShape :: T n -> T n -> T (Vec2 tag n)
- verticalVal :: Value val => val (Vec2 tag n) -> val n
- horizontalVal :: Value val => val (Vec2 tag n) -> val n
Documentation
I choose a bit complicated Dim2 definition to make it distinct from size pairs with width and height swapped. Alternatives would be Index.Linear or intentionally complicated Shape types like:
type Dim0 = () type Dim1 = ((), Size) type Dim2 = ((), Size, Size)
Problems with Index.Linear is that it is fixed to Word32 dimensions which causes trouble with negative coordinates that we encounter on rotations.
The custom shape type requires lots of new definitions but it is certainly the cleanest solution.
Constructors
| Vec2 | |
Fields
| |
Instances
| Storable n => Storable (Vec2 tag n) | |
| ((~) * tag ShapeTag, C i) => C (Vec2 tag i) | |
| Compose n => Compose (Vec2 tag n) | |
| Decompose p => Decompose (Vec2 tag p) | |
| C i => C (Vec2 tag i) | |
| C n => C (Vec2 tag n) | |
| Compose n => Compose (Vec2 tag n) | |
| Decompose pn => Decompose (Vec2 tag pn) | |
| type Repr f (Vec2 tag n) = Vec2 tag (Repr f n) | |
| type Decomposed f (Vec2 tag pat) = Vec2 tag (Decomposed f pat) | |
| type Index (Vec2 tag i) = Index2 (Index i) | |
| type Composed (Vec2 tag n) = Vec2 tag (Composed n) | |
| type Struct (Vec2 tag i) = Struct (Struct i, (Struct i, ())) | |
| type Composed (Vec2 tag n) = Vec2 tag (Composed n) | |
| type PatternTuple (Vec2 tag pat) = Vec2 tag (PatternTuple pat) |
squareShape :: n -> Vec2 tag n Source
castToElemPtr :: Ptr (Vec2 tag a) -> Ptr a Source
verticalVal :: Value val => val (Vec2 tag n) -> val n Source
horizontalVal :: Value val => val (Vec2 tag n) -> val n Source