tysv
Types
Values
pub fn from_fs(
builder: Builder(a),
fs: file_stream.FileStream,
acc: acc,
add: fn(acc, a) -> acc,
) -> acc
pub fn from_fs_with_rest(
builder: Builder(a),
fs: file_stream.FileStream,
acc: acc,
add: fn(acc, #(a, List(String))) -> acc,
) -> acc
pub fn from_text(
builder: Builder(a),
text: String,
acc: acc,
add: fn(acc, a) -> acc,
) -> acc
pub fn from_text_with_rest(
builder: Builder(a),
text: String,
acc: acc,
add: fn(acc, #(a, List(String))) -> acc,
) -> acc
pub fn multi_col(
builder: Builder(fn(a) -> b),
count: Int,
parse: fn(List(String)) -> Result(a, Nil),
) -> Builder(b)
Parse list of values from a given number of columns.
const landmarks = "# Landmark,x,y
Parthenon,37.971528,23.726639
Stonehenge,51.178829,-1.826183
Colosseo,41.890251,12.492373"
const landmark_rows = [
#("Parthenon", [37.971528, 23.726639]),
#("Stonehenge", [51.178829, -1.826183]),
#("Colosseo", [41.890251, 12.492373]),
]
assert landmark_rows
== tysv.build({
use name <- tysv.parsed
use coordinates <- tysv.parsed
#(name, coordinates)
})
|> tysv.col(Ok)
|> tysv.multi_col(2, fn(tokens) {
tokens |> list.map(float.parse) |> result.all
})
|> tysv.from_text(landmarks, list.new(), list.prepend)
|> list.reverse
pub fn row_sep(
builder: Builder(a),
row_sep: String,
) -> Builder(a)
Set row separator.
WARN: This does not work when the source provided in from is a FileStream
pub fn run(
builder: Builder(a),
acc: acc,
add: fn(acc, #(a, List(String))) -> acc,
) -> acc