License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Language.Syntax.Direction
Contents
Description
Types and helper functions for working with directions
Synopsis
- data Direction
- data CoordinateOrientation
- data AbsoluteDir
- data RelativeDir
- data PlanarRelativeDir
- directionSyntax :: Direction -> Text
- isCardinal :: Direction -> Bool
- allDirs :: [Direction]
- directionJsonModifier :: String -> String
- getCoordinateOrientation :: AbsoluteDir -> CoordinateOrientation
Directions
The type of directions. Used e.g. to indicate which way a robot will turn.
Constructors
DAbsolute AbsoluteDir | |
DRelative RelativeDir |
Instances
data CoordinateOrientation Source #
Constructors
Latitudinal | |
Longitudinal |
Instances
Show CoordinateOrientation Source # | |
Defined in Swarm.Language.Syntax.Direction Methods showsPrec :: Int -> CoordinateOrientation -> ShowS # show :: CoordinateOrientation -> String # showList :: [CoordinateOrientation] -> ShowS # | |
Eq CoordinateOrientation Source # | |
Defined in Swarm.Language.Syntax.Direction Methods (==) :: CoordinateOrientation -> CoordinateOrientation -> Bool # (/=) :: CoordinateOrientation -> CoordinateOrientation -> Bool # | |
Ord CoordinateOrientation Source # | |
Defined in Swarm.Language.Syntax.Direction Methods compare :: CoordinateOrientation -> CoordinateOrientation -> Ordering # (<) :: CoordinateOrientation -> CoordinateOrientation -> Bool # (<=) :: CoordinateOrientation -> CoordinateOrientation -> Bool # (>) :: CoordinateOrientation -> CoordinateOrientation -> Bool # (>=) :: CoordinateOrientation -> CoordinateOrientation -> Bool # max :: CoordinateOrientation -> CoordinateOrientation -> CoordinateOrientation # min :: CoordinateOrientation -> CoordinateOrientation -> CoordinateOrientation # |
data AbsoluteDir Source #
An absolute direction is one which is defined with respect to an external frame of reference; robots need a compass in order to use them.
NOTE: These values are ordered by increasing angle according to the standard mathematical convention. That is, the right-pointing direction, East, is considered the "reference angle" and the order proceeds counter-clockwise. See https://en.wikipedia.org/wiki/Polar_coordinate_system#Conventions
Do not alter this ordering, as there exist functions that depend on it
(e.g. nearestDirection
and relativeTo
).
Instances
FromJSON AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
FromJSONKey AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
ToJSON AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods toJSON :: AbsoluteDir -> Value # toEncoding :: AbsoluteDir -> Encoding # toJSONList :: [AbsoluteDir] -> Value # toEncodingList :: [AbsoluteDir] -> Encoding # omitField :: AbsoluteDir -> Bool # | |||||
ToJSONKey AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods | |||||
Data AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AbsoluteDir -> c AbsoluteDir # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AbsoluteDir # toConstr :: AbsoluteDir -> Constr # dataTypeOf :: AbsoluteDir -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AbsoluteDir) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AbsoluteDir) # gmapT :: (forall b. Data b => b -> b) -> AbsoluteDir -> AbsoluteDir # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AbsoluteDir -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AbsoluteDir -> r # gmapQ :: (forall d. Data d => d -> u) -> AbsoluteDir -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> AbsoluteDir -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AbsoluteDir -> m AbsoluteDir # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsoluteDir -> m AbsoluteDir # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsoluteDir -> m AbsoluteDir # | |||||
Bounded AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
Enum AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods succ :: AbsoluteDir -> AbsoluteDir # pred :: AbsoluteDir -> AbsoluteDir # toEnum :: Int -> AbsoluteDir # fromEnum :: AbsoluteDir -> Int # enumFrom :: AbsoluteDir -> [AbsoluteDir] # enumFromThen :: AbsoluteDir -> AbsoluteDir -> [AbsoluteDir] # enumFromTo :: AbsoluteDir -> AbsoluteDir -> [AbsoluteDir] # enumFromThenTo :: AbsoluteDir -> AbsoluteDir -> AbsoluteDir -> [AbsoluteDir] # | |||||
Generic AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Associated Types
| |||||
Read AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods readsPrec :: Int -> ReadS AbsoluteDir # readList :: ReadS [AbsoluteDir] # readPrec :: ReadPrec AbsoluteDir # readListPrec :: ReadPrec [AbsoluteDir] # | |||||
Show AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods showsPrec :: Int -> AbsoluteDir -> ShowS # show :: AbsoluteDir -> String # showList :: [AbsoluteDir] -> ShowS # | |||||
Eq AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
Ord AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods compare :: AbsoluteDir -> AbsoluteDir -> Ordering # (<) :: AbsoluteDir -> AbsoluteDir -> Bool # (<=) :: AbsoluteDir -> AbsoluteDir -> Bool # (>) :: AbsoluteDir -> AbsoluteDir -> Bool # (>=) :: AbsoluteDir -> AbsoluteDir -> Bool # max :: AbsoluteDir -> AbsoluteDir -> AbsoluteDir # min :: AbsoluteDir -> AbsoluteDir -> AbsoluteDir # | |||||
Hashable AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
type Rep AbsoluteDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction type Rep AbsoluteDir = D1 ('MetaData "AbsoluteDir" "Swarm.Language.Syntax.Direction" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-util" 'False) ((C1 ('MetaCons "DEast" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DNorth" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DWest" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DSouth" 'PrefixI 'False) (U1 :: Type -> Type))) |
data RelativeDir Source #
A relative direction is one which is defined with respect to the robot's frame of reference; no special capability is needed to use them.
Constructors
DPlanar PlanarRelativeDir | |
DDown |
Instances
FromJSON RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
ToJSON RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods toJSON :: RelativeDir -> Value # toEncoding :: RelativeDir -> Encoding # toJSONList :: [RelativeDir] -> Value # toEncodingList :: [RelativeDir] -> Encoding # omitField :: RelativeDir -> Bool # | |||||
Data RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RelativeDir -> c RelativeDir # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RelativeDir # toConstr :: RelativeDir -> Constr # dataTypeOf :: RelativeDir -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RelativeDir) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelativeDir) # gmapT :: (forall b. Data b => b -> b) -> RelativeDir -> RelativeDir # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RelativeDir -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RelativeDir -> r # gmapQ :: (forall d. Data d => d -> u) -> RelativeDir -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> RelativeDir -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RelativeDir -> m RelativeDir # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RelativeDir -> m RelativeDir # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RelativeDir -> m RelativeDir # | |||||
Generic RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Associated Types
| |||||
Read RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods readsPrec :: Int -> ReadS RelativeDir # readList :: ReadS [RelativeDir] # readPrec :: ReadPrec RelativeDir # readListPrec :: ReadPrec [RelativeDir] # | |||||
Show RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods showsPrec :: Int -> RelativeDir -> ShowS # show :: RelativeDir -> String # showList :: [RelativeDir] -> ShowS # | |||||
Eq RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
Ord RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods compare :: RelativeDir -> RelativeDir -> Ordering # (<) :: RelativeDir -> RelativeDir -> Bool # (<=) :: RelativeDir -> RelativeDir -> Bool # (>) :: RelativeDir -> RelativeDir -> Bool # (>=) :: RelativeDir -> RelativeDir -> Bool # max :: RelativeDir -> RelativeDir -> RelativeDir # min :: RelativeDir -> RelativeDir -> RelativeDir # | |||||
Hashable RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
type Rep RelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction type Rep RelativeDir = D1 ('MetaData "RelativeDir" "Swarm.Language.Syntax.Direction" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-util" 'False) (C1 ('MetaCons "DPlanar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 PlanarRelativeDir)) :+: C1 ('MetaCons "DDown" 'PrefixI 'False) (U1 :: Type -> Type)) |
data PlanarRelativeDir Source #
Caution: Do not alter this ordering, as there exist functions that depend on it
(e.g. nearestDirection
and relativeTo
).
Instances
FromJSON PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods parseJSON :: Value -> Parser PlanarRelativeDir # parseJSONList :: Value -> Parser [PlanarRelativeDir] # | |||||
ToJSON PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods toJSON :: PlanarRelativeDir -> Value # toEncoding :: PlanarRelativeDir -> Encoding # toJSONList :: [PlanarRelativeDir] -> Value # toEncodingList :: [PlanarRelativeDir] -> Encoding # omitField :: PlanarRelativeDir -> Bool # | |||||
Data PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PlanarRelativeDir -> c PlanarRelativeDir # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PlanarRelativeDir # toConstr :: PlanarRelativeDir -> Constr # dataTypeOf :: PlanarRelativeDir -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PlanarRelativeDir) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PlanarRelativeDir) # gmapT :: (forall b. Data b => b -> b) -> PlanarRelativeDir -> PlanarRelativeDir # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PlanarRelativeDir -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PlanarRelativeDir -> r # gmapQ :: (forall d. Data d => d -> u) -> PlanarRelativeDir -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PlanarRelativeDir -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PlanarRelativeDir -> m PlanarRelativeDir # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PlanarRelativeDir -> m PlanarRelativeDir # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PlanarRelativeDir -> m PlanarRelativeDir # | |||||
Bounded PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
Enum PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods succ :: PlanarRelativeDir -> PlanarRelativeDir # pred :: PlanarRelativeDir -> PlanarRelativeDir # toEnum :: Int -> PlanarRelativeDir # fromEnum :: PlanarRelativeDir -> Int # enumFrom :: PlanarRelativeDir -> [PlanarRelativeDir] # enumFromThen :: PlanarRelativeDir -> PlanarRelativeDir -> [PlanarRelativeDir] # enumFromTo :: PlanarRelativeDir -> PlanarRelativeDir -> [PlanarRelativeDir] # enumFromThenTo :: PlanarRelativeDir -> PlanarRelativeDir -> PlanarRelativeDir -> [PlanarRelativeDir] # | |||||
Generic PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Associated Types
Methods from :: PlanarRelativeDir -> Rep PlanarRelativeDir x # to :: Rep PlanarRelativeDir x -> PlanarRelativeDir # | |||||
Read PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods readsPrec :: Int -> ReadS PlanarRelativeDir # readList :: ReadS [PlanarRelativeDir] # | |||||
Show PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods showsPrec :: Int -> PlanarRelativeDir -> ShowS # show :: PlanarRelativeDir -> String # showList :: [PlanarRelativeDir] -> ShowS # | |||||
Eq PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods (==) :: PlanarRelativeDir -> PlanarRelativeDir -> Bool # (/=) :: PlanarRelativeDir -> PlanarRelativeDir -> Bool # | |||||
Ord PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction Methods compare :: PlanarRelativeDir -> PlanarRelativeDir -> Ordering # (<) :: PlanarRelativeDir -> PlanarRelativeDir -> Bool # (<=) :: PlanarRelativeDir -> PlanarRelativeDir -> Bool # (>) :: PlanarRelativeDir -> PlanarRelativeDir -> Bool # (>=) :: PlanarRelativeDir -> PlanarRelativeDir -> Bool # max :: PlanarRelativeDir -> PlanarRelativeDir -> PlanarRelativeDir # min :: PlanarRelativeDir -> PlanarRelativeDir -> PlanarRelativeDir # | |||||
Hashable PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction | |||||
type Rep PlanarRelativeDir Source # | |||||
Defined in Swarm.Language.Syntax.Direction type Rep PlanarRelativeDir = D1 ('MetaData "PlanarRelativeDir" "Swarm.Language.Syntax.Direction" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-util" 'False) ((C1 ('MetaCons "DForward" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DLeft" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DBack" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DRight" 'PrefixI 'False) (U1 :: Type -> Type))) |
directionSyntax :: Direction -> Text Source #
Direction name is generated from the deepest nested data constructor
e.g. DLeft
becomes "left"
directionJsonModifier :: String -> String Source #