Skip to content

Commit 29a3924

Browse files
committed
Update documentation and haddocks for Vect
1 parent f550061 commit 29a3924

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

sdl2.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ library
7272
SDL.Video.Renderer
7373

7474
SDL.Internal.Types
75+
SDL.Internal.Vect
7576

7677
SDL.Raw
7778
SDL.Raw.Audio
@@ -91,7 +92,6 @@ library
9192
other-modules:
9293
Data.Bitmask
9394
SDL.Internal.Numbered
94-
SDL.Internal.Vect
9595
SDL.Exception
9696

9797
hs-source-dirs:

src/SDL/Internal/Vect.hs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,47 @@
11
{-# LANGUAGE ScopedTypeVariables #-}
22
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3+
4+
-- 2-D, 3-D and 4-D Vectors.
5+
-- The interface is compatible with that of the 'linear' package.
36
module SDL.Internal.Vect
47
( V2(..)
58
, V3(..)
69
, V4(..)
710
, Point(..)
811
) where
912

10-
-- Copied from the 'linear' package by Edward Kmett.
13+
-- From the 'linear' package, (c) Edward Kmett.
1114

1215
import Control.Applicative
1316
import Foreign.Storable
1417
import Foreign.Ptr (castPtr)
1518

19+
-- | A handy wrapper to help distinguish points from vectors at the
20+
-- type level.
1621
newtype Point f a = P (f a)
1722
deriving (Show, Read, Ord, Eq, Functor, Applicative, Num, Storable)
1823

24+
-- | A 2-dimensional vector
25+
--
26+
-- >>> pure 1 :: V2 Int
27+
-- V2 1 1
28+
--
29+
-- >>> V2 1 2 + V2 3 4
30+
-- V2 4 6
31+
--
32+
-- >>> V2 1 2 * V2 3 4
33+
-- V2 3 8
34+
--
35+
-- >>> sum (V2 1 2)
36+
-- 3
1937
data V2 a = V2 !a !a
2038
deriving (Show, Read, Ord, Eq)
2139

40+
-- | A 3-dimensional vector
2241
data V3 a = V3 !a !a !a
2342
deriving (Show, Read, Ord, Eq)
2443

44+
-- | A 4-dimensional vector
2545
data V4 a = V4 !a !a !a !a
2646
deriving (Show, Read, Ord, Eq)
2747

src/SDL/Vect.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{-# LANGUAGE CPP #-}
2+
3+
-- | SDL's vector representation.
4+
--
5+
-- By default, re-exports the vector types from the 'linear' package, but this can be changed via the @-no-linear@
6+
-- build flag to export SDL's internal vector types from "SDL.Internal.Vect".
7+
-- This is useful if one does not want to incur the 'lens' dependency.
28
module SDL.Vect
39
( module Vect
410
) where

0 commit comments

Comments
 (0)