[{"name":"WiringDiagram","comment":" Wiring diagrams\n\n\n# Inspiration\n\n<https://arxiv.org/pdf/2101.12046.pdf>\n\n\n# Diagram type\n\n@docs Diagram\n\n\n# Simple use\n\nSee ['WiringDiagram.Simple'](@WiringDiagram.Simple)\n\n@docs init\n\n\n# Custom use\n\n@docs initLabeled, diagram\n\n\n# Diagram helpers\n\n@docs source, sink, relation, inSequence, inParallel, setLabel, setDirection, Direction, include\n\n\n# Input and output Ports\n\n@docs setOutPorts, setInPorts, outPorts, inPorts\n\n\n# Wrapping\n\nParts of a Diagram can be wrapped and given a label of its own (with setLabel)\n\n@docs initWrap, setWrap\n\n\n# Misc\n\n@docs map, Ports, offsetPorts\n\n","unions":[{"name":"Diagram","comment":" Represent an abstract wire-diagram.\n\nThink of boxes connected with ports, that can be inside other boxes (which connect outside)\n(TODO illustration)\n\n","args":["a"],"cases":[["Diagram",["{ label : Maybe.Maybe a, wrap : Basics.Bool, inner : List.List (WiringDiagram.Diagram a), direction : WiringDiagram.Direction, inPorts : WiringDiagram.Ports, outPorts : WiringDiagram.Ports }"]]]},{"name":"Direction","comment":" Direction of composition of diagrams\n\nD1 is horizontal (sequenced, chained)\nD2 is vertical (in paralell)\n\n","args":[],"cases":[["D1",[]],["D2",[]]]}],"aliases":[{"name":"Ports","comment":" Ports are a list of numbers identifying each port\n","args":[],"type":"List.List Basics.Int"}],"values":[{"name":"diagram","comment":" Wrap a diagram, exposing the free in and out ports\n","type":"{ a | label : Maybe.Maybe b, inner : List.List (WiringDiagram.Diagram b) } -> WiringDiagram.Diagram b"},{"name":"inParallel","comment":" Put diagrams in paralell. No connections will be made.\n(We probably need to relabel ports here...)\n","type":"List.List (WiringDiagram.Diagram a) -> WiringDiagram.Diagram a"},{"name":"inPorts","comment":" Extract the input ports of a Diagram\n","type":"WiringDiagram.Diagram a -> WiringDiagram.Ports"},{"name":"inSequence","comment":" Connect diagrams in a chain\n","type":"List.List (WiringDiagram.Diagram a) -> WiringDiagram.Diagram a"},{"name":"include","comment":" Include a list of diagrams inside another diagram.\nThe included list will replace any previous innards.\n","type":"List.List (WiringDiagram.Diagram a) -> WiringDiagram.Diagram a -> WiringDiagram.Diagram a"},{"name":"init","comment":" Initialize an empty Diagram. The idea is a box with no label.\nThe box is abstract and will be given geometry using [the Layout module](@Layout)\n\nUse modifiers like `setInPorts` to configure further\n\n","type":"WiringDiagram.Diagram a"},{"name":"initLabeled","comment":" Initialize an empty Diagram with a label of a chosen type\n\nAll diagrams you intend to combine needs to have the same label type\n\n","type":"Maybe.Maybe a -> WiringDiagram.Diagram a"},{"name":"initWrap","comment":" Wrap a diagram, exposing the free in and out ports\n","type":"WiringDiagram.Diagram a -> WiringDiagram.Diagram a"},{"name":"map","comment":" Map a function over a diagram innards\nYou should avoid using this\n","type":"({ label : Maybe.Maybe a, wrap : Basics.Bool, inner : List.List (WiringDiagram.Diagram a), direction : WiringDiagram.Direction, inPorts : WiringDiagram.Ports, outPorts : WiringDiagram.Ports } -> { label : Maybe.Maybe b, wrap : Basics.Bool, inner : List.List (WiringDiagram.Diagram b), direction : WiringDiagram.Direction, inPorts : WiringDiagram.Ports, outPorts : WiringDiagram.Ports }) -> WiringDiagram.Diagram a -> WiringDiagram.Diagram b"},{"name":"offsetPorts","comment":" Bump the port numbers of a diagram.\n\nThis is used to avoid duplicate ports when combining diagrams in paralell\n(relabel ports here...)\n\n","type":"Basics.Int -> WiringDiagram.Diagram a -> WiringDiagram.Diagram a"},{"name":"outPorts","comment":" Extract the output ports of a Diagram\n","type":"WiringDiagram.Diagram a -> WiringDiagram.Ports"},{"name":"relation","comment":" Make a relation with label a and a number of inPorts and outPorts\n","type":"a -> Basics.Int -> Basics.Int -> WiringDiagram.Diagram a"},{"name":"setDirection","comment":" Say which direction the children should lay out\n","type":"WiringDiagram.Direction -> { a | direction : WiringDiagram.Direction } -> { a | direction : WiringDiagram.Direction }"},{"name":"setInPorts","comment":" Assign input ports to a Diagram\n","type":"List.List Basics.Int -> { a | inPorts : WiringDiagram.Ports } -> { a | inPorts : WiringDiagram.Ports }"},{"name":"setLabel","comment":" Assign a label to a Diagram\n\n    setLabel (Just \"node\") <| diagram --\n\n","type":"Maybe.Maybe a -> WiringDiagram.Diagram a -> WiringDiagram.Diagram a"},{"name":"setOutPorts","comment":" Assign output ports to a Diagram\n","type":"List.List Basics.Int -> { a | outPorts : WiringDiagram.Ports } -> { a | outPorts : WiringDiagram.Ports }"},{"name":"setWrap","comment":" Specify that a diagram exterior is significant\n","type":"a -> { b | wrap : a } -> { b | wrap : a }"},{"name":"sink","comment":" Make a sink with label a and a number of inPorts\n","type":"a -> Basics.Int -> WiringDiagram.Diagram a"},{"name":"source","comment":" Make a source with label a and a number of outPorts\n","type":"a -> Basics.Int -> WiringDiagram.Diagram a"}],"binops":[]},{"name":"WiringDiagram.Examples","comment":" Some example diagrams\n\n@docs sampleDiagrams, a, b, c, a2, b2, c2, twoLanes\n\n","unions":[],"aliases":[],"values":[{"name":"a","comment":" A simple source labeled 'a'\nIt has one output port.\n","type":"WiringDiagram.Examples.Diagram"},{"name":"a2","comment":" A simple source labeled 'a2'\nIt has two output ports\n","type":"WiringDiagram.Examples.Diagram"},{"name":"b","comment":" A simple relation labeled 'b'\nIt has one input and one output port\n","type":"WiringDiagram.Examples.Diagram"},{"name":"b2","comment":" A simple relation labeled 'b2'\nIt has two input and output ports\n","type":"WiringDiagram.Examples.Diagram"},{"name":"c","comment":" A simple sink labeled 'c'\nIt has one input port\n","type":"WiringDiagram.Examples.Diagram"},{"name":"c2","comment":" A simple sink labeled 'c2'\nIt has two input ports\n","type":"WiringDiagram.Examples.Diagram"},{"name":"sampleDiagrams","comment":" A list of some diagrams\n\n    sampleDiagrams : List Diagram\n    sampleDiagrams =\n        [ inSequence [ a, b, c ]\n        , inSequence [ wrap a, wrap b ]\n        , inSequence [ wrap a, wrap (inParallel [ b, c |> offsetPorts 1 ]) ]\n        , wrap_a\n        , inSequence\n            [ wrap (source \"a\" 2)\n            , sink \"b\" 2\n            ]\n        , wrap_axb_c\n        , inSequence [ a, b ]\n        , inSequence [ source \"a3\" 3, sink \"b2\" 2 ]\n        ]\n\n","type":"List.List WiringDiagram.Examples.Diagram"},{"name":"twoLanes","comment":" Two sequenced diagrams in parallel\n\n    inParallel\n        [ inSequence [ a, c ]\n        , inSequence [ source \"d\" 1, sink \"e\" 1 ]\n        ]\n\n","type":"WiringDiagram.Examples.Diagram"}],"binops":[]},{"name":"WiringDiagram.Layout","comment":" Layout of WiringDiagram values\n\nTypically a Layout can be converted to SVG for display\n\n\n# Definition\n\n@docs Layout\n\n\n# Simple Layout of a Diagram\n\n@docs layoutDiagram\n\n\n# Customized Layout of a Diagram\n\n@docs layoutDiagramWithConfig\n\n\n# Misc\n\n@docs Polarity, Pos, Transform, arrowExtent, portPositionsOfBox\n\n","unions":[{"name":"Layout","comment":" The Layout type keeps information about the layout of a Wiring diagram.\n","args":["a"],"cases":[["Group",["{ transform : WiringDiagram.Layout.Transform, exterior : Maybe.Maybe (WiringDiagram.Layout.Box.Box a), interiorTransform : WiringDiagram.Layout.Transform, interior : List.List (WiringDiagram.Layout.Layout a) }"]],["Item",["WiringDiagram.Layout.Box.Box a"]],["Arrow",["{ label : String.String, tail : WiringDiagram.Vec2.Vec2, head : WiringDiagram.Vec2.Vec2 }"]]]},{"name":"Polarity","comment":" Polarity of a Port. Is the port going In or Out of something\n","args":[],"cases":[["In",[]],["Out",[]]]}],"aliases":[{"name":"Pos","comment":" A type for Positions\n","args":[],"type":"WiringDiagram.Vec2.Vec2"},{"name":"Transform","comment":" Transform only supports simple 2d translation\n","args":[],"type":"WiringDiagram.Vec2.Vec2"}],"values":[{"name":"arrowExtent","comment":" Make an extent for an Arrow. This stupidly assumes the tail is < head\n","type":"{ a | tail : b, head : c } -> { lo : b, hi : c }"},{"name":"layoutDiagram","comment":" Layout a Diagram with default configuration\n","type":"WiringDiagram.Diagram a -> WiringDiagram.Layout.Layout a"},{"name":"layoutDiagramWithConfig","comment":" Layout a Diagram with custom configuration\n","type":"WiringDiagram.Layout.Config.Config a -> WiringDiagram.Diagram a -> WiringDiagram.Layout.Layout a"},{"name":"portPositionsOfBox","comment":" List the port positions of a Box, given a Polarity (In,Out)\n","type":"WiringDiagram.Layout.Polarity -> WiringDiagram.Layout.Box.Box a -> List.List ( Basics.Int, WiringDiagram.Layout.Pos )"}],"binops":[]},{"name":"WiringDiagram.Svg","comment":" Convert a Layout of a WireDiagram to SVG\n\n@docs view, Viewport, simpleDiagramToSvg, simpleLayoutToSvg, layoutToSvg, diagramToSvg\n\n\n## Viewport defaults\n\n@docs smallViewport, mediumViewport, wideViewport, largeViewport\n\n\n# Customization\n\n@docs layoutToSvgWithConfig\n\n","unions":[],"aliases":[{"name":"Viewport","comment":" Placement and dimensions of a Viewport to render SVG inside\n","args":[],"type":"{ width : Basics.Float, height : Basics.Float, xMin : Basics.Float, yMin : Basics.Float }"}],"values":[{"name":"diagramToSvg","comment":" Shortcut render a Diagram (via Layout) to Svg\n","type":"WiringDiagram.Diagram a -> Svg.Svg msg"},{"name":"largeViewport","comment":" A larger sized viewport (1024x768)\n","type":"{ width : number, height : number, xMin : number, yMin : number }"},{"name":"layoutToSvg","comment":" Render a Layout to Svg\n","type":"WiringDiagram.Layout.Layout b -> Svg.Svg msg"},{"name":"layoutToSvgWithConfig","comment":" Render a Layout to Svg with configurable labeling\n","type":"WiringDiagram.Svg.Config.Config a -> WiringDiagram.Layout.Layout a -> Svg.Svg msg"},{"name":"mediumViewport","comment":" A medium sized viewport (640x480)\n","type":"{ width : number, height : number, xMin : number, yMin : number }"},{"name":"simpleDiagramToSvg","comment":" Shortcut render a Diagram with String labels (via Layout) to Svg\n","type":"WiringDiagram.Diagram String.String -> Svg.Svg msg"},{"name":"simpleLayoutToSvg","comment":" Render a (Layout String) to Svg\n","type":"WiringDiagram.Layout.Layout String.String -> Svg.Svg msg"},{"name":"smallViewport","comment":" A small viewport of 200x200\n","type":"{ width : number, height : number, xMin : number, yMin : number }"},{"name":"view","comment":" Render a list of Svg items in a viewport to Html\n","type":"WiringDiagram.Svg.Viewport -> List.List (Svg.Svg msg) -> Html.Html msg"},{"name":"wideViewport","comment":" A wide but low viewport of 1200x150\n","type":"{ width : number, height : number, xMin : number, yMin : number }"}],"binops":[]},{"name":"WiringDiagram.Svg.Config","comment":" Configure how to convert Layout Labels to Strings for Svg output\n\n@docs Config, forStringLabels, initWithLabelToString, withLabelToString\n\n\n# Applying the config (You probably won't need to use this, it will be used by `Svg.layoutToSvgWithConfig`)\n\n@docs applyToLabelString\n\n","unions":[{"name":"Config","comment":" Preliminary way to control how labels turn into String for SVG\n","args":["a"],"cases":[]}],"aliases":[],"values":[{"name":"applyToLabelString","comment":" Apply the toLabelString function of the config to a value of type a\n","type":"WiringDiagram.Svg.Config.Config a -> a -> String.String"},{"name":"forStringLabels","comment":" Simple starting config when labels are already String\n","type":"WiringDiagram.Svg.Config.Config String.String"},{"name":"initWithLabelToString","comment":" Init needs a labelToString function\n","type":"(a -> String.String) -> WiringDiagram.Svg.Config.Config a"},{"name":"withLabelToString","comment":" Simple starting config when labels are already String\n","type":"(a -> String.String) -> WiringDiagram.Svg.Config.Config a -> WiringDiagram.Svg.Config.Config a"}],"binops":[]}]