    {-# LANGUAGE CPP, OverloadedStrings #-}
    {-# OPTIONS_HADDOCK hide #-}

    {- |
       Module      : Data.GraphViz.Attributes.Internal
       Description : Internal Attribute value definitions
       Copyright   : (c) Ivan Lazar Miljenovic
       License     : 3-Clause BSD-style
       Maintainer  : Ivan.Miljenovic@gmail.com

       This module is defined so as to avoid exposing internal functions
       in the external API.  These are those that are needed for the
       testsuite.

     -}

    module Data.GraphViz.Attributes.Internal
           ( PortName(..)
           , PortPos(..)
           , CompassPoint(..)
           , compassLookup
           , parseEdgeBasedPP
           ) where

    import Data.GraphViz.Parsing
    import Data.GraphViz.Printing

    import           Data.Map       (Map)
    import qualified Data.Map       as Map
    import           Data.Maybe     (isNothing)
    import           Data.Text.Lazy (Text)

    #if !MIN_VERSION_base (4,13,0)
    import Data.Monoid ((<>))
    #endif

    -- -----------------------------------------------------------------------------

    -- Note that printing and parsing of PortName values is specific to
    -- where it's being used: record- and HTML-like labels print/parse
    -- them differently from when they're on they're part of PortPos; the
    -- default printing and parsing is done for the latter.

    -- Should this really be exported from here?  Or in another common module?

    -- | Specifies a name for ports (used also in record-based and
    --   HTML-like labels).  Note that it is not valid for a 'PortName'
    --   value to contain a colon (@:@) character; it is assumed that it
    --   doesn't.
    newtype PortName = PN { PortName -> Text
    portName :: Text }
                     deriving (PortName -> PortName -> Bool
    (PortName -> PortName -> Bool)
    -> (PortName -> PortName -> Bool) -> Eq PortName
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PortName -> PortName -> Bool
    == :: PortName -> PortName -> Bool
    $c/= :: PortName -> PortName -> Bool
    /= :: PortName -> PortName -> Bool
    Eq, Eq PortName
    Eq PortName =>
    (PortName -> PortName -> Ordering)
    -> (PortName -> PortName -> Bool)
    -> (PortName -> PortName -> Bool)
    -> (PortName -> PortName -> Bool)
    -> (PortName -> PortName -> Bool)
    -> (PortName -> PortName -> PortName)
    -> (PortName -> PortName -> PortName)
    -> Ord PortName
    PortName -> PortName -> Bool
    PortName -> PortName -> Ordering
    PortName -> PortName -> PortName
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: PortName -> PortName -> Ordering
    compare :: PortName -> PortName -> Ordering
    $c< :: PortName -> PortName -> Bool
    < :: PortName -> PortName -> Bool
    $c<= :: PortName -> PortName -> Bool
    <= :: PortName -> PortName -> Bool
    $c> :: PortName -> PortName -> Bool
    > :: PortName -> PortName -> Bool
    $c>= :: PortName -> PortName -> Bool
    >= :: PortName -> PortName -> Bool
    $cmax :: PortName -> PortName -> PortName
    max :: PortName -> PortName -> PortName
    $cmin :: PortName -> PortName -> PortName
    min :: PortName -> PortName -> PortName
    Ord, Int -> PortName -> ShowS
    [PortName] -> ShowS
    PortName -> String
    (Int -> PortName -> ShowS)
    -> (PortName -> String) -> ([PortName] -> ShowS) -> Show PortName
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> PortName -> ShowS
    showsPrec :: Int -> PortName -> ShowS
    $cshow :: PortName -> String
    show :: PortName -> String
    $cshowList :: [PortName] -> ShowS
    showList :: [PortName] -> ShowS
    Show, ReadPrec [PortName]
    ReadPrec PortName
    Int -> ReadS PortName
    ReadS [PortName]
    (Int -> ReadS PortName)
    -> ReadS [PortName]
    -> ReadPrec PortName
    -> ReadPrec [PortName]
    -> Read PortName
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS PortName
    readsPrec :: Int -> ReadS PortName
    $creadList :: ReadS [PortName]
    readList :: ReadS [PortName]
    $creadPrec :: ReadPrec PortName
    readPrec :: ReadPrec PortName
    $creadListPrec :: ReadPrec [PortName]
    readListPrec :: ReadPrec [PortName]
    Read)

    instance PrintDot PortName where
      unqtDot :: PortName -> DotCode
    unqtDot = Text -> DotCode
    forall a. PrintDot a => a -> DotCode
    unqtDot (Text -> DotCode) -> (PortName -> Text) -> PortName -> DotCode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PortName -> Text
    portName

      toDot :: PortName -> DotCode
    toDot = Text -> DotCode
    forall a. PrintDot a => a -> DotCode
    toDot (Text -> DotCode) -> (PortName -> Text) -> PortName -> DotCode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PortName -> Text
    portName

    instance ParseDot PortName where
      parseUnqt :: Parse PortName
    parseUnqt = Text -> PortName
    PN (Text -> PortName) -> Parser GraphvizState Text -> Parse PortName
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Bool -> String -> String -> Parser GraphvizState Text
    parseEscaped Bool
    False [] [Char
    '"', Char
    ':']

      parse :: Parse PortName
    parse = Parse PortName -> Parse PortName
    forall a. Parse a -> Parse a
    quotedParse Parse PortName
    forall a. ParseDot a => Parse a
    parseUnqt
              Parse PortName -> Parse PortName -> Parse PortName
    forall s a. Parser s a -> Parser s a -> Parser s a
    `onFail`
              Parse PortName
    unqtPortName

    unqtPortName :: Parse PortName
    unqtPortName :: Parse PortName
    unqtPortName = Text -> PortName
    PN (Text -> PortName) -> Parser GraphvizState Text -> Parse PortName
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser GraphvizState Text
    quotelessString

    -- -----------------------------------------------------------------------------

    data PortPos = LabelledPort PortName (Maybe CompassPoint)
                 | CompassPoint CompassPoint
                 deriving (PortPos -> PortPos -> Bool
    (PortPos -> PortPos -> Bool)
    -> (PortPos -> PortPos -> Bool) -> Eq PortPos
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PortPos -> PortPos -> Bool
    == :: PortPos -> PortPos -> Bool
    $c/= :: PortPos -> PortPos -> Bool
    /= :: PortPos -> PortPos -> Bool
    Eq, Eq PortPos
    Eq PortPos =>
    (PortPos -> PortPos -> Ordering)
    -> (PortPos -> PortPos -> Bool)
    -> (PortPos -> PortPos -> Bool)
    -> (PortPos -> PortPos -> Bool)
    -> (PortPos -> PortPos -> Bool)
    -> (PortPos -> PortPos -> PortPos)
    -> (PortPos -> PortPos -> PortPos)
    -> Ord PortPos
    PortPos -> PortPos -> Bool
    PortPos -> PortPos -> Ordering
    PortPos -> PortPos -> PortPos
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: PortPos -> PortPos -> Ordering
    compare :: PortPos -> PortPos -> Ordering
    $c< :: PortPos -> PortPos -> Bool
    < :: PortPos -> PortPos -> Bool
    $c<= :: PortPos -> PortPos -> Bool
    <= :: PortPos -> PortPos -> Bool
    $c> :: PortPos -> PortPos -> Bool
    > :: PortPos -> PortPos -> Bool
    $c>= :: PortPos -> PortPos -> Bool
    >= :: PortPos -> PortPos -> Bool
    $cmax :: PortPos -> PortPos -> PortPos
    max :: PortPos -> PortPos -> PortPos
    $cmin :: PortPos -> PortPos -> PortPos
    min :: PortPos -> PortPos -> PortPos
    Ord, Int -> PortPos -> ShowS
    [PortPos] -> ShowS
    PortPos -> String
    (Int -> PortPos -> ShowS)
    -> (PortPos -> String) -> ([PortPos] -> ShowS) -> Show PortPos
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> PortPos -> ShowS
    showsPrec :: Int -> PortPos -> ShowS
    $cshow :: PortPos -> String
    show :: PortPos -> String
    $cshowList :: [PortPos] -> ShowS
    showList :: [PortPos] -> ShowS
    Show, ReadPrec [PortPos]
    ReadPrec PortPos
    Int -> ReadS PortPos
    ReadS [PortPos]
    (Int -> ReadS PortPos)
    -> ReadS [PortPos]
    -> ReadPrec PortPos
    -> ReadPrec [PortPos]
    -> Read PortPos
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS PortPos
    readsPrec :: Int -> ReadS PortPos
    $creadList :: ReadS [PortPos]
    readList :: ReadS [PortPos]
    $creadPrec :: ReadPrec PortPos
    readPrec :: ReadPrec PortPos
    $creadListPrec :: ReadPrec [PortPos]
    readListPrec :: ReadPrec [PortPos]
    Read)

    instance PrintDot PortPos where
      unqtDot :: PortPos -> DotCode
    unqtDot (LabelledPort PortName
    n Maybe CompassPoint
    mc) = PortName -> DotCode
    forall a. PrintDot a => a -> DotCode
    unqtDot PortName
    n
                                    DotCode -> DotCode -> DotCode
    forall a. Semigroup a => a -> a -> a
    <> DotCode -> (DotCode -> DotCode) -> Maybe DotCode -> DotCode
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe DotCode
    forall (m :: * -> *). Applicative m => m Doc
    empty (DotCode
    forall (m :: * -> *). Applicative m => m Doc
    colon DotCode -> DotCode -> DotCode
    forall a. Semigroup a => a -> a -> a
    <>) ((CompassPoint -> DotCode) -> Maybe CompassPoint -> Maybe DotCode
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap CompassPoint -> DotCode
    forall a. PrintDot a => a -> DotCode
    unqtDot Maybe CompassPoint
    mc)
      unqtDot (CompassPoint CompassPoint
    cp)   = CompassPoint -> DotCode
    forall a. PrintDot a => a -> DotCode
    unqtDot CompassPoint
    cp

      toDot :: PortPos -> DotCode
    toDot (LabelledPort PortName
    n Maybe CompassPoint
    Nothing) = PortName -> DotCode
    forall a. PrintDot a => a -> DotCode
    toDot PortName
    n
      toDot lp :: PortPos
    lp@LabelledPort{}        = DotCode -> DotCode
    forall (m :: * -> *). Functor m => m Doc -> m Doc
    dquotes (DotCode -> DotCode) -> DotCode -> DotCode
    forall a b. (a -> b) -> a -> b
    $ PortPos -> DotCode
    forall a. PrintDot a => a -> DotCode
    unqtDot PortPos
    lp
      toDot PortPos
    cp                       = PortPos -> DotCode
    forall a. PrintDot a => a -> DotCode
    unqtDot PortPos
    cp

    instance ParseDot PortPos where
      parseUnqt :: Parse PortPos
    parseUnqt = do n <- Parse PortName
    forall a. ParseDot a => Parse a
    parseUnqt
                     mc <- optional $ character ':' >> parseUnqt
                     return $ if isNothing mc
                              then checkPortName n
                              else LabelledPort n mc

      parse :: Parse PortPos
    parse = Parse PortPos -> Parse PortPos
    forall a. Parse a -> Parse a
    quotedParse Parse PortPos
    forall a. ParseDot a => Parse a
    parseUnqt
              Parse PortPos -> Parse PortPos -> Parse PortPos
    forall s a. Parser s a -> Parser s a -> Parser s a
    `onFail`
              (PortName -> PortPos) -> Parse PortName -> Parse PortPos
    forall a b.
    (a -> b) -> Parser GraphvizState a -> Parser GraphvizState b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap PortName -> PortPos
    checkPortName Parse PortName
    unqtPortName

    checkPortName    :: PortName -> PortPos
    checkPortName :: PortName -> PortPos
    checkPortName PortName
    pn = PortPos
    -> (CompassPoint -> PortPos) -> Maybe CompassPoint -> PortPos
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (PortName -> Maybe CompassPoint -> PortPos
    LabelledPort PortName
    pn Maybe CompassPoint
    forall a. Maybe a
    Nothing) CompassPoint -> PortPos
    CompassPoint
                       (Maybe CompassPoint -> PortPos)
    -> (Text -> Maybe CompassPoint) -> Text -> PortPos
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text -> Map Text CompassPoint -> Maybe CompassPoint
    forall k a. Ord k => k -> Map k a -> Maybe a
    `Map.lookup` Map Text CompassPoint
    compassLookup)
                       (Text -> PortPos) -> Text -> PortPos
    forall a b. (a -> b) -> a -> b
    $ PortName -> Text
    portName PortName
    pn

    -- | When attached to a node in a DotEdge definition, the 'PortName'
    --   and the 'CompassPoint' can be in separate quotes.
    parseEdgeBasedPP :: Parse PortPos
    parseEdgeBasedPP :: Parse PortPos
    parseEdgeBasedPP = (PortName -> Maybe CompassPoint -> PortPos)
    -> Parse PortName
    -> Parser GraphvizState (Maybe CompassPoint)
    -> Parse PortPos
    forall a b c.
    (a -> b -> c)
    -> Parser GraphvizState a
    -> Parser GraphvizState b
    -> Parser GraphvizState c
    forall (f :: * -> *) a b c.
    Applicative f =>
    (a -> b -> c) -> f a -> f b -> f c
    liftA2 PortName -> Maybe CompassPoint -> PortPos
    LabelledPort Parse PortName
    forall a. ParseDot a => Parse a
    parse ((CompassPoint -> Maybe CompassPoint)
    -> Parser GraphvizState CompassPoint
    -> Parser GraphvizState (Maybe CompassPoint)
    forall a b.
    (a -> b) -> Parser GraphvizState a -> Parser GraphvizState b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap CompassPoint -> Maybe CompassPoint
    forall a. a -> Maybe a
    Just (Parser GraphvizState CompassPoint
     -> Parser GraphvizState (Maybe CompassPoint))
    -> Parser GraphvizState CompassPoint
    -> Parser GraphvizState (Maybe CompassPoint)
    forall a b. (a -> b) -> a -> b
    $ Char -> Parse Char
    character Char
    ':' Parse Char
    -> Parser GraphvizState CompassPoint
    -> Parser GraphvizState CompassPoint
    forall a b.
    Parser GraphvizState a
    -> Parser GraphvizState b -> Parser GraphvizState b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser GraphvizState CompassPoint
    forall a. ParseDot a => Parse a
    parse)
                       Parse PortPos -> Parse PortPos -> Parse PortPos
    forall s a. Parser s a -> Parser s a -> Parser s a
    `onFail`
                       Parse PortPos
    forall a. ParseDot a => Parse a
    parse

    data CompassPoint = North
                      | NorthEast
                      | East
                      | SouthEast
                      | South
                      | SouthWest
                      | West
                      | NorthWest
                      | CenterPoint
                      | NoCP
                      deriving (CompassPoint -> CompassPoint -> Bool
    (CompassPoint -> CompassPoint -> Bool)
    -> (CompassPoint -> CompassPoint -> Bool) -> Eq CompassPoint
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CompassPoint -> CompassPoint -> Bool
    == :: CompassPoint -> CompassPoint -> Bool
    $c/= :: CompassPoint -> CompassPoint -> Bool
    /= :: CompassPoint -> CompassPoint -> Bool
    Eq, Eq CompassPoint
    Eq CompassPoint =>
    (CompassPoint -> CompassPoint -> Ordering)
    -> (CompassPoint -> CompassPoint -> Bool)
    -> (CompassPoint -> CompassPoint -> Bool)
    -> (CompassPoint -> CompassPoint -> Bool)
    -> (CompassPoint -> CompassPoint -> Bool)
    -> (CompassPoint -> CompassPoint -> CompassPoint)
    -> (CompassPoint -> CompassPoint -> CompassPoint)
    -> Ord CompassPoint
    CompassPoint -> CompassPoint -> Bool
    CompassPoint -> CompassPoint -> Ordering
    CompassPoint -> CompassPoint -> CompassPoint
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: CompassPoint -> CompassPoint -> Ordering
    compare :: CompassPoint -> CompassPoint -> Ordering
    $c< :: CompassPoint -> CompassPoint -> Bool
    < :: CompassPoint -> CompassPoint -> Bool
    $c<= :: CompassPoint -> CompassPoint -> Bool
    <= :: CompassPoint -> CompassPoint -> Bool
    $c> :: CompassPoint -> CompassPoint -> Bool
    > :: CompassPoint -> CompassPoint -> Bool
    $c>= :: CompassPoint -> CompassPoint -> Bool
    >= :: CompassPoint -> CompassPoint -> Bool
    $cmax :: CompassPoint -> CompassPoint -> CompassPoint
    max :: CompassPoint -> CompassPoint -> CompassPoint
    $cmin :: CompassPoint -> CompassPoint -> CompassPoint
    min :: CompassPoint -> CompassPoint -> CompassPoint
    Ord, CompassPoint
    CompassPoint -> CompassPoint -> Bounded CompassPoint
    forall a. a -> a -> Bounded a
    $cminBound :: CompassPoint
    minBound :: CompassPoint
    $cmaxBound :: CompassPoint
    maxBound :: CompassPoint
    Bounded, Int -> CompassPoint
    CompassPoint -> Int
    CompassPoint -> [CompassPoint]
    CompassPoint -> CompassPoint
    CompassPoint -> CompassPoint -> [CompassPoint]
    CompassPoint -> CompassPoint -> CompassPoint -> [CompassPoint]
    (CompassPoint -> CompassPoint)
    -> (CompassPoint -> CompassPoint)
    -> (Int -> CompassPoint)
    -> (CompassPoint -> Int)
    -> (CompassPoint -> [CompassPoint])
    -> (CompassPoint -> CompassPoint -> [CompassPoint])
    -> (CompassPoint -> CompassPoint -> [CompassPoint])
    -> (CompassPoint -> CompassPoint -> CompassPoint -> [CompassPoint])
    -> Enum CompassPoint
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: CompassPoint -> CompassPoint
    succ :: CompassPoint -> CompassPoint
    $cpred :: CompassPoint -> CompassPoint
    pred :: CompassPoint -> CompassPoint
    $ctoEnum :: Int -> CompassPoint
    toEnum :: Int -> CompassPoint
    $cfromEnum :: CompassPoint -> Int
    fromEnum :: CompassPoint -> Int
    $cenumFrom :: CompassPoint -> [CompassPoint]
    enumFrom :: CompassPoint -> [CompassPoint]
    $cenumFromThen :: CompassPoint -> CompassPoint -> [CompassPoint]
    enumFromThen :: CompassPoint -> CompassPoint -> [CompassPoint]
    $cenumFromTo :: CompassPoint -> CompassPoint -> [CompassPoint]
    enumFromTo :: CompassPoint -> CompassPoint -> [CompassPoint]
    $cenumFromThenTo :: CompassPoint -> CompassPoint -> CompassPoint -> [CompassPoint]
    enumFromThenTo :: CompassPoint -> CompassPoint -> CompassPoint -> [CompassPoint]
    Enum, Int -> CompassPoint -> ShowS
    [CompassPoint] -> ShowS
    CompassPoint -> String
    (Int -> CompassPoint -> ShowS)
    -> (CompassPoint -> String)
    -> ([CompassPoint] -> ShowS)
    -> Show CompassPoint
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CompassPoint -> ShowS
    showsPrec :: Int -> CompassPoint -> ShowS
    $cshow :: CompassPoint -> String
    show :: CompassPoint -> String
    $cshowList :: [CompassPoint] -> ShowS
    showList :: [CompassPoint] -> ShowS
    Show, ReadPrec [CompassPoint]
    ReadPrec CompassPoint
    Int -> ReadS CompassPoint
    ReadS [CompassPoint]
    (Int -> ReadS CompassPoint)
    -> ReadS [CompassPoint]
    -> ReadPrec CompassPoint
    -> ReadPrec [CompassPoint]
    -> Read CompassPoint
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS CompassPoint
    readsPrec :: Int -> ReadS CompassPoint
    $creadList :: ReadS [CompassPoint]
    readList :: ReadS [CompassPoint]
    $creadPrec :: ReadPrec CompassPoint
    readPrec :: ReadPrec CompassPoint
    $creadListPrec :: ReadPrec [CompassPoint]
    readListPrec :: ReadPrec [CompassPoint]
    Read)

    instance PrintDot CompassPoint where
      unqtDot :: CompassPoint -> DotCode
    unqtDot CompassPoint
    NorthEast   = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "ne"
      unqtDot CompassPoint
    NorthWest   = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "nw"
      unqtDot CompassPoint
    North       = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "n"
      unqtDot CompassPoint
    East        = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "e"
      unqtDot CompassPoint
    SouthEast   = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "se"
      unqtDot CompassPoint
    SouthWest   = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "sw"
      unqtDot CompassPoint
    South       = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "s"
      unqtDot CompassPoint
    West        = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "w"
      unqtDot CompassPoint
    CenterPoint = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "c"
      unqtDot CompassPoint
    NoCP        = Text -> DotCode
    forall (m :: * -> *). Applicative m => Text -> m Doc
    text Text
    "_"

    instance ParseDot CompassPoint where
      -- Have to take care of longer parsing values first.
      parseUnqt :: Parser GraphvizState CompassPoint
    parseUnqt = [Parser GraphvizState CompassPoint]
    -> Parser GraphvizState CompassPoint
    forall (p :: * -> *) a. PolyParse p => [p a] -> p a
    oneOf [ CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    NorthEast String
    "ne"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    NorthWest String
    "nw"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    North String
    "n"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    SouthEast String
    "se"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    SouthWest String
    "sw"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    South String
    "s"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    East String
    "e"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    West String
    "w"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    CenterPoint String
    "c"
                        , CompassPoint -> String -> Parser GraphvizState CompassPoint
    forall a. a -> String -> Parse a
    stringRep CompassPoint
    NoCP String
    "_"
                        ]

    compassLookup :: Map Text CompassPoint
    compassLookup :: Map Text CompassPoint
    compassLookup = [(Text, CompassPoint)] -> Map Text CompassPoint
    forall k a. Ord k => [(k, a)] -> Map k a
    Map.fromList [ (Text
    "ne", CompassPoint
    NorthEast)
                                 , (Text
    "nw", CompassPoint
    NorthWest)
                                 , (Text
    "n", CompassPoint
    North)
                                 , (Text
    "e", CompassPoint
    East)
                                 , (Text
    "se", CompassPoint
    SouthEast)
                                 , (Text
    "sw", CompassPoint
    SouthWest)
                                 , (Text
    "s", CompassPoint
    South)
                                 , (Text
    "w", CompassPoint
    West)
                                 , (Text
    "c", CompassPoint
    CenterPoint)
                                 , (Text
    "_", CompassPoint
    NoCP)
                                 ]

    -- -----------------------------------------------------------------------------