Re:Fantastic DSLs and where to find them
by sillysaurus3 on Thursday June 29, 2017 @12:32PM
(#14664584)
How would you call it? I'm interested in how you'd specify `I` and `O`.
`I` is obviously a string, but it seems like `O` needs to be at least three different types:
> (reduce (fn (x y)
(list x y))
(list "a"))
"a"
> (reduce (fn (x y)
(list x y))
(list "a" "b"))
("a" "b")
> (reduce (fn (x y)
(list x y))
(list "a" "b" "c"))
("a" ("b" "c"))
Re:Fantastic DSLs and where to find them
by lilactown on Thursday June 29, 2017 @01:03PM
(#14664877)
`O` would be whatever the type of the reducer is, so for `list` in the lisp you're using (is it Clojure? The function params look wrong) has a type signature `(A, B?, ...Z?) -> A | List(A, B, ...Z)`.
So the transducer in this case would have the type `List(A, B?, ...Z?) -> A | List(A, B | List(B, ...etc))`
It's not three different types, but it is necessarily recursive, which seems tricky.
I feel like I'm missing something here. I would think it would just be