Re: [stack] sweetening concatenative syntax
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Mar 6, 2008, at 5:36 PM, William Tanksley, Jr wrote: > John Nowak <[email protected]> wrote: >> William Tanksley, Jr wrote: >>> ...but you're still doing patternmatching. Aren't you? What am I >>> missing? >> 'unlist' is just a normal function that gets defined as a result of >> declaring the 'list' data type: >> unlist :: A {b} [A -> C] [A b {b} -> C] -> C > > Sorry, I have no idea how to read this. It's clearly a type signature, > but I don't know any such languages more recent than ML (well, I know > a little Scala), and that only from a few college assignments. > > I assumed that it was somewhat like 'i' in Joy (due to the name > 'unlist' being similar to Joy's technical term 'dequote'). I explained what 'unlist' does in an earlier email. You may've missed it. The 'unlist' function is not like 'i' in Joy. Joy's 'i' has the following type: i :: A [A -> B] -> B In other words, given a stack and a function that transforms that stack to another stack, it yields the transformed stack. What 'unlist' does is take three arguments. The first is a list. The second is a function that says what to do if that list is null. The the third is a function that acts on the list after is has been unconsed if it is not null. The 'unlist' function is called a sum deconstructor as lists are sum types (they're either a "null" or a "cons"). We can use 'unlist' to write the usual functions: uncons = [error] [] unlist head = [error] [pop] unlist tail = [error] [popd] unlist null? = [true] [cons false] unlist - John