{-# OPTIONS -Wall #-}---------------------------------------------------------------------------------- |-- Module : Wumpus.Basic.Kernel.Objects.Connector-- Copyright : (c) Stephen Tetley 2011-- License : BSD3---- Maintainer : stephen.tetley@gmail.com-- Stability : highly unstable-- Portability : GHC ---- ConnImage and ConnGraphic types - these are functional types-- from the DrawingContext plus start point and end point to a -- graphic /primitive/.----------------------------------------------------------------------------------moduleWumpus.Basic.Kernel.Objects.Connector(ConnectorImage,ConnectorGraphic,DConnectorImage,DConnectorGraphic,intoConnectorImage,connectorGraphic_,emptyConnectorGraphic,uconvConnectorImageF,uconvConnectorImageZ)whereimportWumpus.Basic.Kernel.Base.BaseDefsimportWumpus.Basic.Kernel.Base.ContextFunimportWumpus.Basic.Kernel.Objects.BasisimportWumpus.Basic.Kernel.Objects.LocImageimportControl.Applicative-- | ConnectorImage - function from DrawingContext and start and -- end points to a polymorphic /answer/ and a graphic /primitive/.--typeConnectorImageua=ConnectorQueryu(ImageAnsua)-- | ConnectorGraphic - function from DrawingContext and start and -- end points to a graphic /primitive/.--typeConnectorGraphicu=ConnectorQueryu(GraphicAnsu)-- | Type specialized version of 'ConnectorImage'.--typeDConnectorImagea=ConnectorImageDoublea-- | Type specialized version of 'ConnectorGraphic'.--typeDConnectorGraphic=ConnectorGraphicDouble-- | 'intoConnectorImage' : @ conn_query * conn_graphic -> LocImage @---- /Connector/ version of 'intoImage'. -- -- The 'ConnectorImage' is built as a function from an implicit -- start and end points to the answer.--intoConnectorImage::ConnectorQueryua->ConnectorGraphicu->ConnectorImageuaintoConnectorImageqfma=promoteR2$\ab->replaceAns<$>apply2R2qfab<*>apply2R2maab-- | /Downcast/ an 'ConnectorImage' to a 'ConnectorGraphic'.-- -- This means forgetting the answer of the Image, replacing it -- with @()@.--connectorGraphic_::ConnectorImageua->ConnectorGraphicuconnectorGraphic_=(fmap.fmap.fmap)ignoreAns-- | 'emptyConnectorGraphic' : @ ConnectorGraphic @---- Build an empty 'ConnectorGraphic'.-- -- The 'emptyConnectorGraphic' is treated as a /null primitive/ by -- @Wumpus-Core@ and is not drawn, although it does generate a -- bounding box around the rectangular hull of the start and end -- points.-- emptyConnectorGraphic::InterpretUnitu=>ConnectorGraphicuemptyConnectorGraphic=promoteR2$\startend->leta=emptyLocGraphic`at`startb=emptyLocGraphic`at`endina`oplus`b-- | Use this to convert 'ConnectorGraphic' or 'ConnectorImage' -- with Functor answer.--uconvConnectorImageF::(InterpretUnitu,InterpretUnitu1,Functort)=>ConnectorImageu(tu)->ConnectorImageu1(tu1)uconvConnectorImageF=uconvR2abszconvAnsF-- | Use this to convert 'ConnectorImage' with unit-less answer.--uconvConnectorImageZ::(InterpretUnitu,InterpretUnitu1)=>ConnectorImageua->ConnectorImageu1auconvConnectorImageZ=uconvR2abszconvAnsZ------------------------------------------------------------------------------------ Design note - potentially there are no useful combining -- operators on Connectors (!).---- Division - i.e. splitting a path at points between the start -- and end - seems a more obvious operation on connector paths -- than combination. See the ConnectorPath operations in -- Wumpus-Drawing for some examples.--