[{"name":"Tracery","comment":" Tracery is a text-generation language mostly used for twitter bots.\n\nSee [Tracery.io](www.tracery.io) for more information.\n\n@docs fromJson, fromSyntax\n\n","unions":[],"aliases":[],"values":[{"name":"fromJson","comment":" Turns a tracery json-string into a generator\n\nA tracery json is a object that has a `origin` field.\n\n    import Json.Decode\n    import Random\n    import Result.Extra\n\n    seed : Random.Seed\n    seed =\n        Random.initialSeed 40\n\n    generate : String -> String\n    generate json =\n        json\n            |> Tracery.fromJson\n            |> Result.Extra.unpack\n                Json.Decode.errorToString\n                (\\generator ->\n                    Random.step generator seed\n                        |> Tuple.first\n                )\n\nYou can reference other fields using `#..#`\n\n    \"\"\"\n    { \"origin\": \"I have two pets: a #pet# and a #pet#\"\n    , \"pet\": [\"cat\",\"dog\",\"fish\",\"parrot\"]\n    }\n    \"\"\"\n    |> generate\n    --> \"I have two pets: a fish and a cat\"\n\nDefinitions may also be recursive.\n\n    \"\"\"\n    { \"origin\": \"I have #pets#\"\n    , \"pets\": [\"a #pet#\",\"a #pet# and #pets#\"]\n    , \"pet\": [\"cat\",\"dog\",\"fish\",\"parrot\"]\n    }\n    \"\"\"\n    |> generate\n    --> \"I have a cat and a dog\"\n\nYou can define constants by providing a string instead of a list.\n\n    \"\"\"\n    { \"origin\": \"My #favoritePet# is the best #favoritePet# in the world\"\n    , \"favoritePet\" : \"#pet#\"\n    , \"pet\": [\"cat\",\"dog\",\"fish\",\"parrot\"]\n    }\n    \"\"\"\n    |> generate\n    --> \"My fish is the best fish in the world\"\n\nYou may define sub-definitions to organize your definitions.\n\n    \"\"\"\n    { \"origin\": [\"My #cat#\",\"My #dog#\"]\n    , \"cat\":\n      { \"origin\":\"cat is named #name#\"\n      , \"name\": [\"Cleopatra\",\"Cesar\"]\n      }\n    , \"dog\":\n      { \"origin\":\"dog is named #name#\"\n      , \"name\": [\"Athena\",\"Zeus\"]\n      }\n    }\n    \"\"\"\n    |> generate\n    --> \"My dog is named Athena\"\n\n","type":"String.String -> Result.Result Json.Decode.Error (Random.Generator String.String)"},{"name":"fromSyntax","comment":" Creates a string generator based on a syntax.\n","type":"Tracery.Syntax.Syntax -> Random.Generator String.String"}],"binops":[]},{"name":"Tracery.Syntax","comment":" This modules exposes the internal structures of the package.\n\nIts intended to be used in combination with some preprocessing.\n\n@docs Syntax, Expression, Definition\n@docs decoder, fromString, originString\n\n","unions":[{"name":"Definition","comment":" The definition specifies how the strings gets generated\n\n  - `Choose` - Choose a random sentence out of a list.\n  - `Let` - Generate the sentence one. Then use the sentence over and over again.\n  - `With` - Generate the sentence according to the sub-grammar.\n\n","args":[],"cases":[["Choose",["List.List (List.List Tracery.Syntax.Expression)"]],["Let",["List.List Tracery.Syntax.Expression"]],["With",["Tracery.Syntax.Syntax"]]]},{"name":"Expression","comment":" The expressions always return a string\n\n  - `Print` - just return the given string\n  - `Insert` - look up the key and insert a generated string according to the definition of the key.\n\n","args":[],"cases":[["Print",["String.String"]],["Insert",["String.String"]]]}],"aliases":[{"name":"Syntax","comment":" The Syntax is just a dictionary of keys and their definition.\n","args":[],"type":"Dict.Dict String.String Tracery.Syntax.Definition"}],"values":[{"name":"decoder","comment":" Decoder for the Syntax.\n","type":"Json.Decode.Decoder Tracery.Syntax.Syntax"},{"name":"fromString","comment":"\n\n    import Dict\n\n    input : String\n    input =\n       \"\"\"{ \"origin\" : [ \"Hello \\\\\\\\\\\\\\\\ World \\\\\\\\#\", \"#statement# and #statement#\" ]\n       , \"statement\" :\n         { \"origin\" : \"my #myPet# is the #complement#\"\n         , \"myPet\": \"#pet#\"\n         , \"pet\" : [\"cat\",\"dog\"]\n         , \"complement\" : [\"smartest #myPet# in the world\",\"fastest #myPet# that i know of\"]\n         }\n       }\"\"\"\n\n    output : Syntax\n    output =\n        Dict.fromList\n            [ ( \"origin\"\n              , Choose\n                  [ [Print \"Hello \", Print \"\\\\\", Print \" World \",Print \"#\"]\n                  , [Insert \"statement\", Print \" and \", Insert \"statement\"]\n                  ]\n              )\n            , ( \"statement\"\n              , Dict.fromList\n                  [ ( \"origin\"\n                    , Let [ Print \"my \", Insert \"myPet\", Print \" is the \", Insert \"complement\"]\n                    )\n                  , ( \"myPet\",Let [Insert \"pet\"])\n                  , ( \"pet\", Choose [[Print \"cat\"],[Print \"dog\"]])\n                  , ( \"complement\"\n                    , Choose\n                        [ [ Print \"smartest \", Insert \"myPet\", Print \" in the world\"]\n                        , [ Print \"fastest \", Insert \"myPet\", Print \" that i know of\"]\n                        ]\n                    )\n                  ]\n                    |> With\n                )\n            ]\n\n    input |> fromString\n    --> Ok output\n\n","type":"String.String -> Result.Result Json.Decode.Error Tracery.Syntax.Syntax"},{"name":"originString","comment":" The origin is the starting point for the generated story.\n\n    originString : String\n    originString =\n        \"origin\"\n\n","type":"String.String"}],"binops":[]}]