helm 0.3.0 → 0.3.1
raw patch · 6 files changed
+37/−40 lines, 6 filesdep ~SDLdep ~cairodep ~containersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: SDL, cairo, containers, elerea, filepath
API changes (from Hackage documentation)
- FRP.Helm.Automaton: (<<<) :: Automaton b c -> Automaton a b -> Automaton a c
- FRP.Helm.Automaton: (>>>) :: Automaton a b -> Automaton b c -> Automaton a c
+ FRP.Helm.Automaton: instance Arrow Automaton
+ FRP.Helm.Automaton: instance Category Automaton
+ FRP.Helm.Color: instance Eq Color
+ FRP.Helm.Color: instance Eq Gradient
+ FRP.Helm.Color: instance Show Color
+ FRP.Helm.Color: instance Show Gradient
+ FRP.Helm.Graphics: instance Enum LineCap
+ FRP.Helm.Graphics: instance Eq Element
+ FRP.Helm.Graphics: instance Eq FillStyle
+ FRP.Helm.Graphics: instance Eq Form
+ FRP.Helm.Graphics: instance Eq FormStyle
+ FRP.Helm.Graphics: instance Eq LineCap
+ FRP.Helm.Graphics: instance Eq LineJoin
+ FRP.Helm.Graphics: instance Eq LineStyle
+ FRP.Helm.Graphics: instance Eq Shape
+ FRP.Helm.Graphics: instance Eq Text
+ FRP.Helm.Graphics: instance Ord LineCap
+ FRP.Helm.Graphics: instance Show Element
+ FRP.Helm.Graphics: instance Show FillStyle
+ FRP.Helm.Graphics: instance Show Form
+ FRP.Helm.Graphics: instance Show FormStyle
+ FRP.Helm.Graphics: instance Show LineCap
+ FRP.Helm.Graphics: instance Show LineJoin
+ FRP.Helm.Graphics: instance Show LineStyle
+ FRP.Helm.Graphics: instance Show Shape
+ FRP.Helm.Graphics: instance Show Text
+ FRP.Helm.Keyboard: instance Eq Key
+ FRP.Helm.Keyboard: instance Ord Key
+ FRP.Helm.Keyboard: instance Show Key
+ FRP.Helm.Mouse: instance Eq Mouse
+ FRP.Helm.Mouse: instance Ord Mouse
+ FRP.Helm.Mouse: instance Show Mouse
Files
- FRP/Helm/Automaton.hs +16/−21
- FRP/Helm/Color.hs +2/−2
- FRP/Helm/Graphics.hs +11/−9
- FRP/Helm/Keyboard.hs +1/−1
- FRP/Helm/Mouse.hs +1/−1
- helm.cabal +6/−6
FRP/Helm/Automaton.hs view
@@ -6,14 +6,15 @@ pure, stateful, combine,- (>>>),- (<<<), -- * Computing step, run, counter ) where +import Control.Arrow+import Control.Category+import Prelude hiding (id, (.)) import FRP.Elerea.Simple (Signal, SignalGen, transfer) {-| A data structure describing an automaton.@@ -24,6 +25,15 @@ to create composable dynamic behavior, like animation systems. -} data Automaton a b = Step (a -> (Automaton a b, b)) +instance Category Automaton where+ id = Step (\a -> (id, a))+ (Step f) . (Step g) = Step (\a -> let (g', b) = g a+ (f', c) = f b in (f' . g', c))++instance Arrow Automaton where+ arr = pure+ first (Step f) = Step (\(b, d) -> let (f', c) = f b in (first f', (c, d)))+ {-| Creates a pure automaton that has no accumulated state. It applies input to a function at each step. -} pure :: (a -> b) -> Automaton a b@@ -32,8 +42,7 @@ {-| Creates an automaton that has an initial and accumulated state. It applies input and the last state to a function at each step. -} stateful :: b -> (a -> b -> b) -> Automaton a b-stateful s f = Step (\x -> let s' = f x s- in (stateful s' f, s'))+stateful state f = Step (\x -> let state' = f x state in (stateful state' f, state')) {-| Steps an automaton forward, returning the next automaton to step and output of the step in a tuple. -}@@ -49,20 +58,6 @@ Step (\a -> let (autos', bs) = unzip $ map (step a) autos in (combine autos', bs)) -{-| Pipes two automatons together. It essentially- returns an automaton that takes the input of the first- automaton and outputs the output of the second automaton,- with the directly connected values being discarded. -}-(>>>) :: Automaton a b -> Automaton b c -> Automaton a c-f >>> g =- Step (\a -> let (f', b) = step a f- (g', c) = step b g- in (f' >>> g', c))--{-| Pipes two automatons in the opposite order of '>>>'. -}-(<<<) :: Automaton b c -> Automaton a b -> Automaton a c-g <<< f = f >>> g- {-| A useful automaton that outputs the amount of times it has been stepped, discarding its input value. -} counter :: Automaton a Int@@ -72,7 +67,7 @@ and creates an output signal generator that contains a signal that can be sampled for the output value. -} run :: Automaton a b -> b -> SignalGen (Signal a) -> SignalGen (Signal b)-run auto initial feeder = do- stepper <- feeder >>= transfer (auto, initial) (\a (Step f, _) -> f a)+run auto ini feeder = do+ food <- feeder >>= transfer (auto, ini) (\a (Step f, _) -> f a) - return $ fmap snd stepper+ return $ fmap snd food
FRP/Helm/Color.hs view
@@ -34,7 +34,7 @@ {-| A data structure describing a color. It is represented interally as an RGBA color, but the utility functions 'hsva', 'hsv', etc. can be used to convert from other popular formats to this structure. -}-data Color = Color { r :: !Double, g :: !Double, b :: !Double, a :: !Double }+data Color = Color { r :: !Double, g :: !Double, b :: !Double, a :: !Double } deriving (Show, Eq) {-| Creates an RGB color. -} rgb :: Double -> Double -> Double -> Color@@ -153,7 +153,7 @@ over certain radii in an arc pattern. Linear gradients are a set of colors transitioned in a straight line. -} data Gradient = Linear (Double, Double) (Double, Double) [(Double, Color)] |- Radial (Double, Double) Double (Double, Double) Double [(Double, Color)]+ Radial (Double, Double) Double (Double, Double) Double [(Double, Color)] deriving (Show, Eq) {-| Creates a linear gradient. Takes a starting position, ending position and a list
FRP/Helm/Graphics.hs view
@@ -63,7 +63,7 @@ renders a collection of forms together. -} data Element = CollageElement Int Int [Form] | ImageElement (Int, Int) Int Int FilePath Bool |- TextElement Text+ TextElement Text deriving (Show, Eq) {-| A data structure describing a piece of formatted text. -} data Text = Text {@@ -73,7 +73,7 @@ fontSize :: Double, fontWeight :: Cairo.FontWeight, fontSlant :: Cairo.FontSlant-}+} deriving (Show, Eq) {-| Create an element from an image with a given width, height and image file path. If the image dimensions are not the same as given, then it will stretch/shrink to fit.@@ -102,18 +102,18 @@ x :: Double, y :: Double, style :: FormStyle-}+} deriving (Show, Eq) {-| A data structure describing how a shape or path looks when filled. -}-data FillStyle = Solid Color | Texture String | Gradient Gradient+data FillStyle = Solid Color | Texture String | Gradient Gradient deriving (Show, Eq) {-| A data structure describing the shape of the ends of a line. -}-data LineCap = Flat | Round | Padded+data LineCap = Flat | Round | Padded deriving (Show, Eq, Enum, Ord) {-| A data structure describing the shape of the join of a line, i.e. where separate line segments join. The 'Sharp' variant takes an argument to limit the length of the join. -}-data LineJoin = Smooth | Sharp Double | Clipped+data LineJoin = Smooth | Sharp Double | Clipped deriving (Show, Eq) {-| A data structure describing how a shape or path looks when stroked. -} data LineStyle = LineStyle {@@ -123,7 +123,7 @@ join :: LineJoin, dashing :: [Double], dashOffset :: Double-}+} deriving (Show, Eq) {-| Creates the default line style. By default, the line is black with a width of 1, flat caps and regular sharp joints. -}@@ -154,7 +154,7 @@ data FormStyle = PathForm LineStyle Path | ShapeForm (Either LineStyle FillStyle) Shape | ElementForm Element |- GroupForm Matrix [Form]+ GroupForm Matrix [Form] deriving (Show, Eq) {-| Utility function for creating a form. -} form :: FormStyle -> Form@@ -243,7 +243,9 @@ {-| A data structure describing a some sort of graphically representable object, such as a polygon formed from a set of points or a rectangle. -}-data Shape = PolygonShape Path | RectangleShape (Double, Double) | ArcShape (Double, Double) Double Double Double (Double, Double)+data Shape = PolygonShape Path |+ RectangleShape (Double, Double) |+ ArcShape (Double, Double) Double Double Double (Double, Double) deriving (Show, Eq) {-| Creates a shape from a path (a set of points). -} polygon :: Path -> Shape
FRP/Helm/Keyboard.hs view
@@ -50,7 +50,7 @@ RShiftKey | LShiftKey | RCtrlKey | LCtrlKey | RAltKey | LAltKey | RMetaKey | LMetaKey | RSuperKey | LSuperKey | ModeKey | ComposeKey | HelpKey | PrintKey | SysReqKey | BreakKey | MenuKey | PowerKey | EuroKey |- UndoKey+ UndoKey deriving (Show, Eq, Ord) {- All integer values of this enum are equivalent to the SDL key enum. -} instance Enum Key where
FRP/Helm/Mouse.hs view
@@ -14,7 +14,7 @@ import qualified Graphics.UI.SDL.Utilities as Util {-| A data structure describing a button on a mouse. -}-data Mouse = LeftMouse | MiddleMouse | RightMouse+data Mouse = LeftMouse | MiddleMouse | RightMouse deriving (Show, Eq, Ord) {- All integer values of this enum are equivalent to the SDL key enum. -} instance Enum Mouse where
helm.cabal view
@@ -1,5 +1,5 @@ name: helm-version: 0.3.0+version: 0.3.1 synopsis: A functionally reactive game engine. description: A functionally reactive game engine, with headgear to protect you from the headache of game development provided.@@ -33,11 +33,11 @@ FRP.Helm.Window build-depends: base >= 4 && < 5,- cairo >= 0.12.4 && < 1,- containers >= 0.5.0.0 && < 1,- elerea >= 2.7.0.1 && < 3,- filepath >= 1.3.0.1 && < 2,- SDL >= 0.6.4 && < 1+ cairo >= 0.12 && < 1,+ containers >= 0.5 && < 1,+ elerea >= 2.7 && < 3,+ filepath >= 1.3 && < 2,+ SDL >= 0.6 && < 1 default-language: Haskell2010 default-extensions: RecordWildCards, NamedFieldPuns ghc-options: -Wall