-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A different take on an IO system. Based on Amanda's IO loop, this eventloop takes a function that maps input events to output events. It can easily be extended by modules that represent IO devices or join multiple modules together. -- @package eventloop @version 0.3.0.0 module Eventloop.Utility.Vectors type Angle = Float type Radians = Float type Length = Float type X = Float type Y = Float type Offset = (X, Y) data PolarCoord PolarCoord :: (Length, Radians) -> PolarCoord data Point Point :: (X, Y) -> Point degreesToRadians :: Angle -> Radians radiansToDegrees :: Radians -> Angle lengthToPoint :: Point -> Length lengthBetweenPoints :: Point -> Point -> Length differenceBetweenPoints :: Point -> Point -> (X, Y) originPoint :: Point class RotateLeftAround a => Vector2D a (|+|) :: Vector2D a => a -> a -> a (|-|) :: Vector2D a => a -> a -> a negateVector :: Vector2D a => a -> a class ToPoint a toPoint :: ToPoint a => a -> Point class ToPolarCoord a toPolarCoord :: ToPolarCoord a => a -> PolarCoord class RotateLeftAround a rotateLeftAround :: RotateLeftAround a => Point -> Angle -> a -> a instance Show PolarCoord instance Eq PolarCoord instance Show Point instance Eq Point instance RotateLeftAround Point instance RotateLeftAround PolarCoord instance ToPolarCoord Point instance ToPoint PolarCoord instance Vector2D Point instance Vector2D PolarCoord module Eventloop.Types.Common type NamedId = [Char] type NumericId = Int module Eventloop.Types.EventTypes type EventloopModuleIdentifier = [Char] type Initializer = SharedIOState -> IOState -> IO (SharedIOState, IOState) type EventRetriever = SharedIOState -> IOState -> IO (SharedIOState, IOState, [In]) type PreProcessor = SharedIOState -> IOState -> In -> IO (SharedIOState, IOState, [In]) type PostProcessor = SharedIOState -> IOState -> Out -> IO (SharedIOState, IOState, [Out]) type EventSender = SharedIOState -> IOState -> Out -> IO (SharedIOState, IOState) type Teardown = SharedIOState -> IOState -> IO (SharedIOState, IOState) type OutEventRouter = Out -> EventloopModuleIdentifier data EventloopModuleConfiguration EventloopModuleConfiguration :: EventloopModuleIdentifier -> IOState -> Maybe Initializer -> Maybe EventRetriever -> Maybe PreProcessor -> Maybe PostProcessor -> Maybe Teardown -> Maybe EventSender -> EventloopModuleConfiguration moduleIdentifier :: EventloopModuleConfiguration -> EventloopModuleIdentifier iostate :: EventloopModuleConfiguration -> IOState initializer :: EventloopModuleConfiguration -> Maybe Initializer eventRetriever :: EventloopModuleConfiguration -> Maybe EventRetriever preprocessor :: EventloopModuleConfiguration -> Maybe PreProcessor postprocessor :: EventloopModuleConfiguration -> Maybe PostProcessor teardown :: EventloopModuleConfiguration -> Maybe Teardown eventSender :: EventloopModuleConfiguration -> Maybe EventSender data EventloopConfiguration progstateT EventloopConfiguration :: progstateT -> (progstateT -> In -> (progstateT, [Out])) -> OutEventRouter -> SharedIOState -> [EventloopModuleConfiguration] -> EventloopConfiguration progstateT progState :: EventloopConfiguration progstateT -> progstateT eventloopFunc :: EventloopConfiguration progstateT -> progstateT -> In -> (progstateT, [Out]) outRouter :: EventloopConfiguration progstateT -> OutEventRouter sharedIOState :: EventloopConfiguration progstateT -> SharedIOState moduleConfigurations :: EventloopConfiguration progstateT -> [EventloopModuleConfiguration] data In Start :: In InKeyboard :: Keyboard -> In InMouse :: Mouse -> In InFile :: FileIn -> In InTimer :: TimerIn -> In InStdIn :: StdInIn -> In InCanvas :: CanvasIn -> In data Out OutFile :: FileOut -> Out OutTimer :: TimerOut -> Out OutStdOut :: StdOutOut -> Out OutStdIn :: StdInOut -> Out OutCanvas :: CanvasOut -> Out OutBasicShapes :: BasicShapesOut -> Out OutDrawTrees :: DrawTreesOut -> Out Stop :: Out data SharedIOState SharedIOState :: (CanvasText -> IO ScreenDimensions) -> SharedIOState measureText :: SharedIOState -> CanvasText -> IO ScreenDimensions data IOState MouseState :: BufferedReceiveBuffer -> Connection -> Socket -> IOState receiveBuffer :: IOState -> BufferedReceiveBuffer clientConnection :: IOState -> Connection serverSocket :: IOState -> Socket KeyboardState :: BufferedReceiveBuffer -> Connection -> Socket -> IOState receiveBuffer :: IOState -> BufferedReceiveBuffer clientConnection :: IOState -> Connection serverSocket :: IOState -> Socket CanvasState :: ReceiveBuffer -> CanvasUserReceiveBuffer -> CanvasSystemReceiveBuffer -> Connection -> Socket -> ThreadId -> IOState commonReceiveBuffer :: IOState -> ReceiveBuffer canvasUserReceiveBuffer :: IOState -> CanvasUserReceiveBuffer canvasSystemReceiveBuffer :: IOState -> CanvasSystemReceiveBuffer clientConnection :: IOState -> Connection serverSocket :: IOState -> Socket routerThreadId :: IOState -> ThreadId StdInState :: [StdInIn] -> IOState newStdInInEvents :: IOState -> [StdInIn] TimerState :: [StartedTimer] -> [StartedTimer] -> IncomingTickBuffer -> IncomingTickBuffer -> IOState startedIntervalTimers :: IOState -> [StartedTimer] startedTimers :: IOState -> [StartedTimer] incomingIntervalTickBuffer :: IOState -> IncomingTickBuffer incomingTickBuffer :: IOState -> IncomingTickBuffer FileState :: [FileIn] -> [OpenFile] -> IOState newFileInEvents :: IOState -> [FileIn] opened :: IOState -> [OpenFile] NoState :: IOState type APIName = [Char] type Parameter = [Char] type Value = [Char] type Parameters = [(Parameter, Value)] instance Eq In instance Show In instance Eq Out instance Show Out module Eventloop.Module.Websocket.Canvas defaultCanvasModuleConfiguration :: EventloopModuleConfiguration defaultCanvasModuleIOState :: IOState canvasModuleIdentifier :: EventloopModuleIdentifier canvasInitializer :: Initializer canvasEventRetriever :: EventRetriever canvasEventSender :: EventSender canvasTeardown :: Teardown sendRoutedMessageOut :: Connection -> RoutedMessageOut -> IO () router :: ReceiveBuffer -> CanvasUserReceiveBuffer -> CanvasSystemReceiveBuffer -> IO () measureText :: IOState -> CanvasId -> CanvasText -> IO ScreenDimensions type CanvasUserReceiveBuffer = MVar [CanvasIn] type CanvasSystemReceiveBuffer = MVar SystemCanvasIn type Opcode = Int type ScreenMetric = Int type ScreenX = ScreenMetric type ScreenY = ScreenMetric type ScreenWidth = ScreenMetric type ScreenHeight = ScreenMetric type ScreenRadius = ScreenMetric type ScreenAngle = ScreenMetric type ScreenPoint = (ScreenX, ScreenY) type ScreenDimensions = (ScreenWidth, ScreenHeight) type ScreenStartingPoint = ScreenPoint type ScreenControlPoint = ScreenPoint type ScreenEndPoint = ScreenPoint type ScreenStartingAngle = ScreenAngle type ScreenEndAngle = ScreenAngle type CanvasId = NumericId type ZIndex = Int type ScreenColorMetric = Int type ScreenRed = ScreenColorMetric type ScreenGreen = ScreenColorMetric type ScreenBlue = ScreenColorMetric type ScreenAlpha = Float type ScreenColor = (ScreenRed, ScreenGreen, ScreenBlue, ScreenAlpha) type ScreenPixel = ScreenColor type ColorStopOffset = Float type ScreenCircle = (ScreenPoint, ScreenRadius) type ScaleUnit = Float type ScaleX = ScaleUnit type ScaleY = ScaleUnit type FontFamily = [Char] type FontSize = Int data RoutedMessageIn InUserCanvas :: CanvasIn -> RoutedMessageIn InSystemCanvas :: SystemCanvasIn -> RoutedMessageIn data RoutedMessageOut OutUserCanvas :: CanvasOut -> RoutedMessageOut OutSystemCanvas :: SystemCanvasOut -> RoutedMessageOut -- | Opcode: 2100 data SystemCanvasIn -- | Opcode: 2101 SystemMeasuredText :: CanvasId -> CanvasText -> ScreenDimensions -> SystemCanvasIn -- | Opcode: 2000 data SystemCanvasOut -- | Opcode: 2001 SystemMeasureText :: CanvasId -> CanvasText -> SystemCanvasOut -- | Opcode: 0100 data CanvasIn -- | Opcode: 0101 MeasuredText :: CanvasId -> CanvasText -> ScreenDimensions -> CanvasIn -- | Reserved type words Type: t | Opcode Arguments: a | List of arguments -- for that data type Route: r | Either s for system or -- u for user Object: o | The object that is beneath -- -- Example: {r: s, o: {SystemMeasuredText -- object}} -- -- SystemMeasuredText object: {t:2102, a:[CanvasId, -- CanvasText object, ScreenDimensions]} -- -- Opcode: 0200 type CanvasPositionLeft = CSSUnit type CanvasPositionRight = CSSUnit type CanvasPosition = (CanvasPositionLeft, CanvasPositionRight) data CanvasOut -- | Opcode: 0201 SetupCanvas :: CanvasId -> ZIndex -> ScreenDimensions -> CanvasPosition -> CanvasOut -- | Opcode: 0202 TeardownCanvas :: CanvasId -> CanvasOut -- | Opcode: 0203 CanvasOperations :: CanvasId -> [CanvasOperation] -> CanvasOut -- | Opcode: 0204 MeasureText :: CanvasId -> CanvasText -> CanvasOut -- | Opcode: 0300 data CanvasOperation -- | Opcode: 0301 DrawPath :: ScreenStartingPoint -> [ScreenPathPart] -> PathStroke -> PathFill -> CanvasOperation -- | Opcode: 0302 DrawText :: CanvasText -> ScreenPoint -> TextRender -> CanvasOperation -- | Opcode: 0303 DoTransform :: CanvasTransform -> CanvasOperation -- | Opcode: 0304 Clear :: ClearPart -> CanvasOperation -- | Opcode: 0400 data ScreenPathPart -- | Opcode: 0401 MoveTo :: ScreenPoint -> ScreenPathPart -- | Opcode: 0402 LineTo :: ScreenPoint -> ScreenPathPart -- | Opcode: 0403 BezierCurveTo :: ScreenControlPoint -> ScreenControlPoint -> ScreenEndPoint -> ScreenPathPart -- | Opcode: 0404 QuadraticCurveTo :: ScreenControlPoint -> ScreenEndPoint -> ScreenPathPart -- | Opcode: 0405 ArcTo :: ScreenControlPoint -> ScreenControlPoint -> ScreenRadius -> ScreenPathPart -- | Opcode: 0406 Arc :: ScreenCircle -> ScreenStartingAngle -> ScreenEndAngle -> ScreenPathPart -- | Opcode: 0407 Rectangle :: ScreenPoint -> ScreenDimensions -> ScreenPathPart -- | Opcode: 0500 type PathRenderStrokeStyle = RenderStyle data PathStroke -- | Opcode: 0501 PathStroke :: PathRenderStrokeStyle -> PathStroke -- | Opcode: 0502 PathNoStroke :: PathStroke -- | Opcode: 0600 type PathRenderFillStyle = RenderStyle data PathFill -- | Opcode: 0601 PathFill :: PathRenderFillStyle -> PathFill -- | Opcode: 0602 PathNoFill :: PathFill -- | Opcode: 0700 type CanvasColorStop = (ColorStopOffset, ScreenColor) data RenderStyle -- | Opcode: 0701 CanvasColor :: ScreenColor -> RenderStyle -- | Opcode:0702 CanvasGradient :: CanvasGradientType -> [CanvasColorStop] -> RenderStyle -- | Opcode: 0703 CanvasPattern :: CanvasImage -> PatternRepetition -> RenderStyle -- | Opcode: 0800 data CanvasImage -- | Opcode: 0801 CanvasElement :: CanvasId -> ScreenPoint -> ScreenDimensions -> CanvasImage -- | Opcode: 0802 [ScreenPixel] should be as long as width * height * 4 ImageData :: ScreenDimensions -> [ScreenPixel] -> CanvasImage -- | Opcode: 0900 data PatternRepetition -- | Opcode: 0901 Repeat :: PatternRepetition -- | Opcode: 0902 RepeatX :: PatternRepetition -- | Opcode: 0903 RepeatY :: PatternRepetition -- | Opcode: 0904 NoRepeat :: PatternRepetition -- | Opcode: 1000 data CanvasGradientType -- | Opcode: 1001 First circle = inner circle, Second circle is enclosing -- circle RadialGradient :: ScreenCircle -> ScreenCircle -> CanvasGradientType -- | Opcode: 1002 LinearGradient :: ScreenPoint -> ScreenPoint -> CanvasGradientType -- | Opcode: 1200 data CanvasText -- | Opcode: 1201 CanvasText :: [Char] -> Font -> Alignment -> CanvasText -- | Opcode: 1300 data Font -- | Opcode: 1301 Font :: FontFamily -> FontSize -> Font -- | Opcode: 1400 type TextStrokeRenderStyle = RenderStyle type TextFillRenderStyle = RenderStyle data TextRender -- | Opcode: 1401 TextStroke :: TextStrokeRenderStyle -> TextRender -- | Opcode: 1402 TextFill :: TextFillRenderStyle -> TextRender -- | Opcode: 1500 data Alignment -- | Opcode: 1501 AlignLeft :: Alignment -- | Opcode: 1502 AlignRight :: Alignment -- | Opcode: 1503 AlignCenter :: Alignment -- | Opcode: 1504 AlignStart :: Alignment -- | Opcode: 1505 AlignEnd :: Alignment -- | Opcode: 1600 type TransformUnit = Float type TransformationMatrix = (TransformUnit, TransformUnit, TransformUnit, TransformUnit, TransformUnit, TransformUnit) data CanvasTransform -- | Opcode: 1601 Save :: CanvasTransform -- | Opcode: 1602 Restore :: CanvasTransform -- | Opcode: 1603 Translate :: ScreenPoint -> CanvasTransform -- | Opcode: 1604 Rotate :: ScreenAngle -> CanvasTransform -- | Opcode: 1605 Scale :: ScaleX -> ScaleY -> CanvasTransform -- | Opcode: 1606 Transform :: TransformationMatrix -> CanvasTransform -- | Opcode: 1607 SetTransform :: TransformationMatrix -> CanvasTransform -- | Opcode: 1608 ResetTransform :: CanvasTransform -- | Opcode: 1800 data CSSUnit -- | Opcode: 1801 CSSPixels :: Int -> CSSUnit -- | Opcode: 1802 CSSPercentage :: Int -> CSSUnit -- | Opcode: 1900 data ClearPart -- | Opcode: 1901 ClearRectangle :: ScreenPoint -> ScreenDimensions -> ClearPart -- | Opcode: 1902 ClearCanvas :: ClearPart module Eventloop.Module.Websocket.Keyboard defaultKeyboardModuleConfiguration :: EventloopModuleConfiguration defaultKeyboardModuleIOState :: IOState keyboardModuleIdentifier :: EventloopModuleIdentifier keyboardInitializer :: Initializer keyboardEventRetriever :: EventRetriever keyboardTeardown :: Teardown data Keyboard Key :: [Char] -> Keyboard module Eventloop.Module.Websocket.Mouse defaultMouseModuleConfiguration :: EventloopModuleConfiguration defaultMouseModuleIOState :: IOState mouseModuleIdentifier :: EventloopModuleIdentifier mouseInitializer :: Initializer mouseEventRetriever :: EventRetriever mouseTeardown :: Teardown type Point = (Float, Float) data Mouse Click :: MouseButton -> Point -> Mouse DoubleClick :: MouseButton -> Point -> Mouse MouseMove :: Point -> Mouse MouseDown :: MouseButton -> Point -> Mouse MouseUp :: MouseButton -> Point -> Mouse MouseEnter :: Point -> Mouse MouseLeave :: Point -> Mouse data MouseButton MouseLeft :: MouseButton MouseRight :: MouseButton MouseMiddle :: MouseButton module Eventloop.Module.DrawTrees data DrawTreesOut DrawTrees :: CanvasId -> [Tree] -> DrawTreesOut data Tree TRBTree :: RBTree -> Tree TRoseTree :: RoseTree -> Tree data NodeColor NodeRed :: NodeColor NodeBlack :: NodeColor NodeGrey :: NodeColor data RBTree RBNode :: NodeColor -> String -> [RBTree] -> RBTree data RoseTree RoseNode :: String -> [RoseTree] -> RoseTree defaultDrawTreesModuleConfiguration :: EventloopModuleConfiguration defaultDrawTreesModuleIOState :: IOState drawTreesModuleIdentifier :: EventloopModuleIdentifier drawTreesPostProcessor :: PostProcessor showGeneralTreeList :: [GeneralTree] -> Shape showGeneralTreeList' :: LeftOffset -> TopOffset -> Float -> Int -> [GeneralTree] -> Shape nodeColorToFillColor :: NodeColor -> FillColor rbExampleTree :: RBTree roseExampleTree :: RoseTree module Eventloop.Module.BasicShapes defaultBasicShapesModuleConfiguration :: EventloopModuleConfiguration defaultBasicShapesModuleIOState :: IOState basicShapesModuleIdentifier :: EventloopModuleIdentifier basicShapesPostProcessor :: PostProcessor type GraphicalNumeric = Float type Translation = Point type Width = GraphicalNumeric type Height = GraphicalNumeric type Dimensions = (Width, Height) type Radius = GraphicalNumeric type Red = GraphicalNumeric type Green = GraphicalNumeric type Blue = GraphicalNumeric type Alpha = GraphicalNumeric type Color = (Red, Green, Blue, Alpha) type FillColor = Color type StrokeColor = Color type ShapeColor = (StrokeColor, FillColor) type UpperLeft = Point type UpperRight = Point type LowerLeft = Point type LowerRight = Point type AmountOfPoints = Int type FontFamily = [Char] type FontSize = GraphicalNumeric data BasicShapesOut DrawShapes :: CanvasId -> [Shape] -> BasicShapesOut data Shape BaseShape :: Primitive -> ShapeColor -> (Maybe Rotation) -> Shape -- | Should contain atleast 1 shape CompositeShape :: [Shape] -> (Maybe Translation) -> (Maybe Rotation) -> Shape data Primitive -- | Translation is upperleftcorner Rectangle :: Translation -> Dimensions -> Primitive translation :: Primitive -> Translation dimensions :: Primitive -> Dimensions -- | Translation is center Circle :: Translation -> Radius -> Primitive translation :: Primitive -> Translation radius :: Primitive -> Radius -- | Translation is center Polygon :: AmountOfPoints -> Translation -> Radius -> Primitive amountOfPoints :: Primitive -> AmountOfPoints translation :: Primitive -> Translation radius :: Primitive -> Radius -- | Translation is center, does not have a boundingbox due to technical -- limitations Text :: [Char] -> FontFamily -> FontSize -> Translation -> Primitive text :: Primitive -> [Char] fontFamily :: Primitive -> FontFamily fontSize :: Primitive -> FontSize translation :: Primitive -> Translation Line :: Point -> Point -> Primitive point1 :: Primitive -> Point point2 :: Primitive -> Point MultiLine :: Point -> Point -> [Point] -> Primitive point1 :: Primitive -> Point point2 :: Primitive -> Point otherPoints :: Primitive -> [Point] data Rotation Rotation :: RotatePoint -> Angle -> Rotation data RotatePoint AroundCenter :: RotatePoint AroundPoint :: Point -> RotatePoint data BoundingBox BoundingBox :: UpperLeft -> UpperRight -> LowerRight -> LowerLeft -> BoundingBox type CanvasId = NumericId module Eventloop.Module.File defaultFileModuleConfiguration :: EventloopModuleConfiguration defaultFileModuleIOState :: IOState fileModuleIdentifier :: EventloopModuleIdentifier fileEventRetriever :: EventRetriever fileEventSender :: EventSender fileTeardown :: Teardown type OpenFile = (FilePath, Handle, IOMode) data FileIn FileOpened :: FilePath -> Bool -> FileIn FileClosed :: FilePath -> Bool -> FileIn RetrievedContents :: FilePath -> [[Char]] -> FileIn RetrievedLine :: FilePath -> [Char] -> FileIn RetrievedChar :: FilePath -> Char -> FileIn IsEOF :: FilePath -> Bool -> FileIn WroteTo :: FilePath -> Bool -> FileIn data FileOut OpenFile :: FilePath -> IOMode -> FileOut CloseFile :: FilePath -> FileOut RetrieveContents :: FilePath -> FileOut RetrieveLine :: FilePath -> FileOut RetrieveChar :: FilePath -> FileOut IfEOF :: FilePath -> FileOut WriteTo :: FilePath -> [Char] -> FileOut module Eventloop.Module.StdIn defaultStdInModuleConfiguration :: EventloopModuleConfiguration defaultStdInModuleIOState :: IOState stdInModuleIdentifier :: EventloopModuleIdentifier stdInEventRetriever :: EventRetriever stdInEventSender :: EventSender data StdInIn StdInReceivedContents :: [[Char]] -> StdInIn StdInReceivedLine :: [Char] -> StdInIn StdInReceivedChar :: Char -> StdInIn data StdInOut StdInReceiveContents :: StdInOut StdInReceiveLine :: StdInOut StdInReceiveChar :: StdInOut module Eventloop.Module.StdOut defaultStdOutModuleConfiguration :: EventloopModuleConfiguration stdOutModuleIdentifier :: EventloopModuleIdentifier stdOutEventSender :: EventSender data StdOutOut StdOutMessage :: [Char] -> StdOutOut module Eventloop.Module.Timer defaultTimerModuleConfiguration :: EventloopModuleConfiguration defaultTimerModuleIOState :: IOState timerModuleIdentifier :: EventloopModuleIdentifier timerInitializer :: Initializer timerEventRetriever :: EventRetriever timerEventSender :: EventSender timerTeardown :: Teardown type MicroSecondDelay = Int type TimerId = [Char] type IncomingTickBuffer = MVar [TimerIn] type StartedTimer = (TimerId, TimerIO) type TimerStartFunction = TimerIO -> IO () -> Delay -> IO Bool data TimerIn Tick :: TimerId -> TimerIn data TimerOut SetTimer :: TimerId -> MicroSecondDelay -> TimerOut SetIntervalTimer :: TimerId -> MicroSecondDelay -> TimerOut UnsetTimer :: TimerId -> TimerOut module Eventloop.RouteEvent routeOutEvent :: OutEventRouter module Eventloop.EventloopCore startMainloop :: EventloopConfiguration progstateT -> IO () module Eventloop.DefaultConfiguration allModulesEventloopConfiguration :: progstateT -> (progstateT -> In -> (progstateT, [Out])) -> EventloopConfiguration progstateT defaultSharedIOState :: SharedIOState