Generating a list of constraints

8 views
Skip to first unread message

Derrick Brinton

unread,
Apr 9, 2011, 8:08:28 PM4/9/11
to byu-cs-330-Winter-2011
My partner and I are having a hard time generating a list of
constraints on paper. For the written assignment, it seems like there
are a number of different ways you could look at the constraints to
generate them and some ways work out with unification, but others
don't. One thing that was really confusing us is when you have to list
a constraint as a function versus just the result of a function. For
example:

Is (+ 1 2) listed as number X number -> number? Or can we just say
it's a number?

We think we probably figured out the written part, but there was
enough confusion that coding the generate constraints function seems
daunting. Is there a list of rules for how to generate constraints
somewhere?

Bryan Morse

unread,
Apr 9, 2011, 8:22:16 PM4/9/11
to byu-cs-330-...@googlegroups.com
It's easiest to just generate the constraints directly.

The "+" operator tells you three things:
[[ (+ 1 2) ]] = number
[[1]] = number
[[2]] = number

The only time you need to put functions in constraints is the type of something *is* a function. For example, for this expression:

{fun {x} {+ x 1}}

if we annotate it with type variables as such:

{fun {x} {+ x 1}}

we know that because the "fun" operator creates functions:

[[ {fun {x} {+ x 1}} ]] = [[x]] -> [[ {+ x 1} ]]

Reply all
Reply to author
Forward
0 new messages