Skip to content

lists are not Scott encoded #2

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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