[
    {
        "name": "Hexagons.Layout",
        "comment": " The next major piece of functionality we need is a way to convert between hex coordinates and screen coordinates. There’s a pointy top layout and a flat top hex layout. The conversion uses a matrix as well as the inverse of the matrix, so we need a way to store those. Also, for drawing the corners, pointy top starts at 30° and flat top starts at 0°, so we need a place to store that too.\n\nSee http://www.redblobgames.com/grids/hexagons/implementation.html for reference.\n\n# Types\n@docs Point, Orientation, Layout\n\n# Contants\n@docs orientationLayoutPointy\n\n# Hex to point and point to hex conversions\n@docs hexToPoint, pointToHex\n\n# Hex to offset and offset to hex coordinate conversions\n@docs hexToOffset, offsetToHex\n\n# Hex corner coordinates\n@docs polygonCorners\n\n# Drawing\n@docs drawLine, drawCircle\n",
        "unions": [],
        "aliases": [
            {
                "name": "Layout",
                "comment": " Composite layout definition ",
                "args": [],
                "type": "{ orientation : Orientation, size : Point, origin : Point }"
            },
            {
                "name": "Orientation",
                "comment": " Orientation helper type to store these: the 2×2 forward matrix, the 2×2 inverse matrix, and the starting angle ",
                "args": [],
                "type": "{ forward_matrix : ( Float, Float, Float, Float ), inverse_matrix : ( Float, Float, Float, Float ), start_angle : Float }"
            },
            {
                "name": "Point",
                "comment": " Point on screen (pixel) ",
                "args": [],
                "type": "( Float, Float )"
            }
        ],
        "values": [
            {
                "name": "drawCircle",
                "comment": " Draw the circle of a defined redius with the hex in a center ",
                "type": "Hex -> Int -> List Hex"
            },
            {
                "name": "drawLine",
                "comment": " Draw the line between hexes using the linear interpolation ",
                "type": "Hex -> Hex -> List Hex"
            },
            {
                "name": "hexToOffset",
                "comment": " Convert Hex coordinates to offset ",
                "type": "Hex -> OffsetCoord"
            },
            {
                "name": "hexToPoint",
                "comment": " Turn Hex coordinates into a Point location on a Layout ",
                "type": "Layout -> Hex -> Point"
            },
            {
                "name": "offsetToHex",
                "comment": " Convert offset coordinates to hex ",
                "type": "OffsetCoord -> Hex"
            },
            {
                "name": "orientationLayoutPointy",
                "comment": " Contant definition of pointy hexagon orientation ",
                "type": "Orientation"
            },
            {
                "name": "pointToHex",
                "comment": " Turn Point coordinates on a Layout into a Hex coordinates ",
                "type": "Layout -> Point -> Hex"
            },
            {
                "name": "polygonCorners",
                "comment": " Once we know where the corners are relative to the center, we can calculate the corners in screen locations by adding the center to each corner, and putting the coordinates into a list. ",
                "type": "Layout -> Hex -> List Point"
            }
        ],
        "binops": []
    },
    {
        "name": "Hexagons.Map",
        "comment": " This module solves the problem of generating and storing the Map data. We are using Elm dictionary as the Map storage engine with Hex coordinate tuple as the key.\n\nSee http://www.redblobgames.com/grids/hexagons/implementation.html for reference.\n\n# Types\n@docs Map, Hash\n\n# Accessing map storage\n@docs hashHex\n@docs getHex\n\n# Map generators\n@docs rectangularPointyTopMap\n",
        "unions": [],
        "aliases": [
            {
                "name": "Hash",
                "comment": " Hash key to access Map cell ",
                "args": [],
                "type": "( Int, Int, Int )"
            },
            {
                "name": "Map",
                "comment": " Dictionary storage to keep map of hexes ",
                "args": [],
                "type": "Dict Hash Hex"
            }
        ],
        "values": [
            {
                "name": "getHex",
                "comment": " Fetch hex from map storage, using a default value in case of missing Hex  ",
                "type": "Hex -> Map -> Hash -> Hex"
            },
            {
                "name": "hashHex",
                "comment": " Hash function to get a uniform token to address stored hex Hex ",
                "type": "Hex -> ( Int, Int, Int )"
            },
            {
                "name": "rectangularPointyTopMap",
                "comment": " Generate Map of rectangular shape given its height and width ",
                "type": "Int -> Int -> Map"
            }
        ],
        "binops": []
    },
    {
        "name": "Hexagons.Hex",
        "comment": " We treat Cube and Axial systems separately. Cube coordinates are a plane in x,y,z space, where x+y+z = 0. Axial coordinates have two axes q,r that are 60° or 120° apart. \n\nSee http://www.redblobgames.com/grids/hexagons/implementation.html\n\n# Types\n@docs Hex, Direction\n\n# Helpers\n@docs q, intQ, r, intR, s, intS, intFactory, floatFactory, toIntHex, toFloatHex\n\n# Equality\n@docs eq, (===), noteq, (!==)\n\n# Coordinate arithmetic\n@docs add, (+++), sub, (=--), mul, (***)\n\n# Distance\n@docs length, distance\n\n# Neighbors\n@docs direction, neighbor\n",
        "unions": [
            {
                "name": "Direction",
                "comment": " Direction ranges from 0 to 5 by sides of the hexagon, we use North, South, West, East definitions for simplicity ",
                "args": [],
                "cases": [
                    [
                        "NE",
                        []
                    ],
                    [
                        "E",
                        []
                    ],
                    [
                        "SE",
                        []
                    ],
                    [
                        "SW",
                        []
                    ],
                    [
                        "W",
                        []
                    ],
                    [
                        "NW",
                        []
                    ]
                ]
            },
            {
                "name": "Hex",
                "comment": " Generic hex field definition ",
                "args": [],
                "cases": [
                    [
                        "FloatCubeHex",
                        [
                            "FloatCubeCoords"
                        ]
                    ],
                    [
                        "IntCubeHex",
                        [
                            "IntCubeCoords"
                        ]
                    ],
                    [
                        "AxialHex",
                        [
                            "AxialCoords"
                        ]
                    ]
                ]
            }
        ],
        "aliases": [],
        "values": [
            {
                "name": "add",
                "comment": " Since cube coordinates come from 3d cartesian coordinates, I automatically get things like addition, subtraction, multiplication, and division. For example, you can have Hex(2, 0, -2) that represents two steps northeast, and add that to location Hex(3, -5, 2) the obvious way: Hex(2 + 3, 0 + -5, -2 + -2). With other coordinate systems like offset coordinates, you can’t do that and get what you want. These operations are just what you’d implement with 3d cartesian vectors, but I am using q, r, s names in this class instead of x, y, z\n\n    IntCubeHex (2, 3, -5) +++ IntCubeHex (1, 2, -3) === IntCubeHex (3, 5, -8)\n",
                "type": "Hex -> Hex -> Hex"
            },
            {
                "name": "direction",
                "comment": " Direction relative to Hex polygon lines, we used shortcuts for the mix of North, East, South, West directions ",
                "type": "Direction -> Hex"
            },
            {
                "name": "distance",
                "comment": " The distance between two hexes is the length of the line between them. \n\n    distance (IntCubeHex (2, 3, -5)) (FloatCubeHex (3.2, 4.3, -7.5)) == 2\n",
                "type": "Hex -> Hex -> Int"
            },
            {
                "name": "eq",
                "comment": " Compare two Hex definitions, support both axial and cubic coordinates.\n\nNot a strict comparation, FloatCubeHex is converted to IntCubeHex.\n\n    IntCubeHex (2, 3, -5) === IntCubeHex (2, 3, -5)\n    AxialHex (2, 3) === AxialHex (2, 3)\n",
                "type": "Hex -> Hex -> Bool"
            },
            {
                "name": "floatFactory",
                "comment": " Build Hex object from Float coordinates\n\n    floatFactory (2.5, 3.5) === FloatCubeHex (2.5, 3.5, -6.0)\n",
                "type": "( Float, Float ) -> Hex"
            },
            {
                "name": "intFactory",
                "comment": " Build Hex object from Int coordinates\n\n    intFactory (2, 3) === IntCubeHex (2, 3, -5)\n",
                "type": "( Int, Int ) -> Hex"
            },
            {
                "name": "intQ",
                "comment": " Get q coordinate for Hex as Int value, its generally not recommended to use on FloatCubeHex\n\n    intQ IntCubeHex (2, 3, -5) == 2\n",
                "type": "Hex -> Int"
            },
            {
                "name": "intR",
                "comment": " Get r coordinate for Hex as Int value, its generally not recommended to use on FloatCubeHex\n\n    intR IntCubeHex (2, 3, -5) == 3\n",
                "type": "Hex -> Int"
            },
            {
                "name": "intS",
                "comment": " Get s coordinate for Hex as Int value, its generally not recommended to use on FloatCubeHex\n\n    intS IntCubeHex (2, 3, -5) == 3\n",
                "type": "Hex -> Int"
            },
            {
                "name": "length",
                "comment": " Length of Hex.\n\n    length (IntCubeHex (2, 3, -5)) == 5\n    length (FloatCubeHex (2.2, 3.3, -5.5)) == 5\n    \n",
                "type": "Hex -> Int"
            },
            {
                "name": "mul",
                "comment": " Multiplication of Hexes, more info in `sum` description\n\n    5 *** (IntCubeHex (2, 3, -5) === IntCubeHex (10, 15, -25))\n",
                "type": "Int -> Hex -> Hex"
            },
            {
                "name": "neighbor",
                "comment": " With distance, we defined two functions: length works on one argument and distance works with two. The same is true with neighbors. The direction function is with one argument and the neighbor function is with two.\n\n    neighbor (IntCubeHex (2, 3, -5)) NW === IntCubeHex (2, 4, -6)\n",
                "type": "Hex -> Direction -> Hex"
            },
            {
                "name": "noteq",
                "comment": " Compare two Hex definitions, if they are not equal, inversion of `eq` \n\n    IntCubeHex (2, 3, -5) !== IntCubeHex (1, 1, -2)\n    AxialHex (2, 3) !== AxialHex (2, 1)\n",
                "type": "Hex -> Hex -> Bool"
            },
            {
                "name": "q",
                "comment": " Get q coordinate for Hex as Float value \n\n    q IntCubeHex (2, 3, -5) == 2.0\n",
                "type": "Hex -> Float"
            },
            {
                "name": "r",
                "comment": " Get r coordinate for Hex as Float value \n\n    r IntCubeHex (2, 3, -5) == 3.0\n",
                "type": "Hex -> Float"
            },
            {
                "name": "s",
                "comment": " Get s coordinate for Hex as Float value \n\n    s IntCubeHex (2, 3, -5) == -5.0\n",
                "type": "Hex -> Float"
            },
            {
                "name": "sub",
                "comment": " Subtraction of Hexes, more info in `sum` description\n\n    (IntCubeHex (2, 3, -5) =-- IntCubeHex (1, 2, -3)) === IntCubeHex (1, 1, -2)\n",
                "type": "Hex -> Hex -> Hex"
            },
            {
                "name": "toFloatHex",
                "comment": " Convert Hex to FloatCubeHex coordinate systems \n\n    toFloatHex (IntCubeHex (2, 3, -5)) === FloatCubeHex (2.0, 3.0, -5.0)\n",
                "type": "Hex -> Hex"
            },
            {
                "name": "toIntHex",
                "comment": " Convert Hex to IntCubeHex coordinate systems \n\n    toIntHex (FloatCubeHex (2.5, 3.5, -6.0)) === IntCubeHex (2, 4, -6)\n",
                "type": "Hex -> Hex"
            }
        ],
        "binops": [
            {
                "name": "!==",
                "comment": " Infixr operator for `noteq` ",
                "type": "Hex -> Hex -> Bool",
                "associativity": "right",
                "precedence": 1
            },
            {
                "name": "***",
                "comment": " Infixr operator for `mul` ",
                "type": "Int -> Hex -> Hex",
                "associativity": "right",
                "precedence": 5
            },
            {
                "name": "+++",
                "comment": " Infixr operator for `sum` ",
                "type": "Hex -> Hex -> Hex",
                "associativity": "right",
                "precedence": 4
            },
            {
                "name": "=--",
                "comment": " Infixr operator for `sub` ",
                "type": "Hex -> Hex -> Hex",
                "associativity": "right",
                "precedence": 4
            },
            {
                "name": "===",
                "comment": " Infixr operator for `eq` ",
                "type": "Hex -> Hex -> Bool",
                "associativity": "right",
                "precedence": 1
            }
        ]
    }
]