Skip to content

lists are not Scott encoded #2

Open
@tromp

Description

@tromp

The encoding of lists in BLC is not a Scott encoding.
Assuming that our list data type is
data List a = Cons a (List a) | Nil
then a Scott encoding would have the same
nil = \c\n. n that BLC uses (i.e. False), but its cons would be
cons = \a\b. \c\n. c a b
which is clearly different. The cons that BLC uses actually corresponds to the stream data type
data Stream a = Cons a (Stream a)
which corresponds to an infinite list. But by some trick, BLC still makes it work for nil terminated lists as well. The trick is that the cons destructor has to accept an extra argument that is the nil deconstructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions