[{"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, run, runTo\n\n@docs step, stepNonRecursive, stepOnlyRecursive\n\n","unions":[],"aliases":[],"values":[{"name":"fromJson","comment":" Turns a tracery json-string into a generator\n\n    import Json.Decode\n    import Random\n    import Result.Extra\n\n    generate : Int -> String -> String\n    generate seed json =\n        json\n            |> Tracery.fromJson\n            |> Result.Extra.unpack\n                Json.Decode.errorToString\n                (\\grammar ->\n                    Random.step (Tracery.run grammar) (Random.initialSeed seed)\n                        |> Tuple.first\n                )\n\nA tracery json is a object that has a `origin` field.\n\nThe `#` and `\\` characters need to be escaped.\n\n    \"\"\"\n    { \"origin\": \"The \\\\\\\\# and \\\\\\\\\\\\\\\\ characters need to be escaped.\"}\n    \"\"\"\n    |> generate 42\n    --> \"The # and \\\\ characters need to be escaped.\"\n\nIf you provide a list, tracer will tick an element at random.\n\n    \"\"\"\n    { \"origin\": [\"I like cats\",\"I like dogs\"]}\n    \"\"\"\n    |> generate 42\n    --> \"I like cats\"\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 42\n    --> \"I have two pets: a dog 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 20\n    --> \"I have a fish and 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 42\n    --> \"My dog is the best dog 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 42\n    --> \"My cat is named Cleopatra\"\n\n","type":"String.String -> Result.Result Json.Decode.Error Tracery.Grammar.Grammar"},{"name":"run","comment":" Runs a grammar until it ends.\n\nSome recursive definitions might take a long time.\n\nUse `runTo` if you want to avoid long waiting times.\n\n","type":"Tracery.Grammar.Grammar -> Random.Generator String.String"},{"name":"runTo","comment":" Runs a grammar until it reaches a key in the list.\n","type":"List.List String.String -> Tracery.Grammar.Grammar -> Random.Generator String.String"},{"name":"step","comment":" compute a single step.\n","type":"Tracery.Grammar.Grammar -> Random.Generator Tracery.Grammar.Grammar"},{"name":"stepNonRecursive","comment":" compute a single step.\n\nThe algorithm will never choose a recursive option for any key in the given list.\n\n","type":"List.List String.String -> Tracery.Grammar.Grammar -> Random.Generator Tracery.Grammar.Grammar"},{"name":"stepOnlyRecursive","comment":" compute a single step.\n\nThe algorithm will always choose a recursive option for any key in the given list.\n\nIf no such option exists, then the empty list will be used instead.\n\n","type":"List.List String.String -> Tracery.Grammar.Grammar -> Random.Generator Tracery.Grammar.Grammar"}],"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 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",["Dict.Dict String.String Tracery.Syntax.Definition"]]]},{"name":"Expression","comment":" The expressions always return a string\n\n  - `Value` - just return the given string\n  - `Variable` - look up the key and insert a generated string according to the definition of the key.\n\n","args":[],"cases":[["Value",["String.String"]],["Variable",["String.String"]]]}],"aliases":[],"values":[{"name":"decoder","comment":" Decoder for the Syntax.\n","type":"Json.Decode.Decoder (Dict.Dict String.String Tracery.Syntax.Definition)"},{"name":"fromString","comment":"\n\n    import Dict exposing (Dict)\n    import Tracery.Trace exposing (Command(..))\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 : Dict String Definition\n    output =\n        Dict.fromList\n            [ ( \"origin\"\n              , Choose\n                  [ [ (Value \"Hello \"),  (Value \"\\\\\"),  (Value \" World \"), (Value \"#\")]\n                  , [ (Variable \"statement\"),  (Value \" and \"),  (Variable \"statement\")]\n                  ]\n              )\n            , ( \"statement\"\n              , Dict.fromList\n                  [ ( \"origin\"\n                    , [  (Value \"my \")\n                      ,  (Variable \"myPet\")\n                      ,  (Value \" is the \")\n                      ,  (Variable \"complement\")\n                      ]\n                        |> Let\n                    )\n                  , ( \"myPet\",Let [ (Variable \"pet\")])\n                  , ( \"pet\", Choose [[ (Value \"cat\")],[ (Value \"dog\")]])\n                  , ( \"complement\"\n                    , Choose\n                        [ [  (Value \"smartest \"),  (Variable \"myPet\"),  (Value \" in the world\")]\n                        , [  (Value \"fastest \"),  (Variable \"myPet\"),  (Value \" 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 (Dict.Dict String.String Tracery.Syntax.Definition)"},{"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":[]}]