lerzegov/elm-markup-fork/1.0.0

NOTE: the latest version is 2.0.0

Formerly lerzegov/elm-markup. Search finds this package by either name.

Mrk.Internal.Id

type Id
= Id String (List Int)
type Seed

We might want to move to a list based ID.

So, when we indent, we're actually adding a level.

Seed [0]


Seed [1] --indent -> Seed [1, 0]
                        |
                        v
                     Seed [1, 1]




Seed [2]

Is there a performance issue with allocating a bunch of lists intead of base Ints?

A very common pattern is to

1. step a seed forward and pass that seed for the next block
2. indent the same original seed, and pass that to the children

So

[0]
    -> stepped [1]  (goes to next element by handing the seed back in the parser)
    -> indented [0,0] (handed to child parser to go nuts with)
dedent : Int -> Seed -> Seed
fromString : String -> Maybe Id
initialSeed : String -> Seed
step : Seed -> ( Id, Seed )
thread : Seed -> List (Seed -> ( Seed, thing )) -> ( Seed, List thing )
threadThrough : (a -> ( b, c )) -> ( a, List c ) -> ( b, List c )
toString : Id -> String