Suggestions for creating a "bind" function that can be applied to different things?

Hi Folks, When I say: "Let x be of datatype Int." I think the proper terminology is "bind". That is, I bind the name "x" to the Int datatype. Is that the correct terminology? Assuming it is, I would like to bind a name to many different things. I seek your suggestions on how to do this. First let dt1, dt2, dt3, dt4 be "DataTypes": dt1, dt2, dt3, dt4 :: DataType And let "Name" be synonymous with String: type Name = String And let title, author, date, cost be "Elements": title, author, date, cost, book :: Element I would like a "bind" function that binds a Name to a DataType to create an Element: bind :: Name -> DataType -> Element Here are a few examples of using bind to create Elements: title = bind "Title" dt4 author = bind "Author" dt4 date = bind "Date" dt4 I would also like to bind a Name to a DataType to create an "Attribute": bind :: Name -> DataType -> Attribute Here's an example of using bind to create an Attribute: currency = bind "Currency" dt3 And I'd like to bind an Attribute to an Element: bind :: Attribute -> Element -> Element Here's an example of binding the currency Attribute to a cost Element: cost = bind currency (bind "Cost" dt1) Finally, I'd like to create an Element by binding a Name to a list of Elements: bind :: Name -> [Element] -> Element Here's an example of this: book = bind "Book" [title, author, date, cost] As you see, I'd like to "bind" to lots of different things. But I can't create multiple functions with the same name, "bind". And I'd rather not create a function for each thing that I want to bind to, e.g., elementBind, attributeBind, attributeToElementBind, multipleElementsBind. There must be an elegant solution. What is your suggestion? /Roger

On Mon, Aug 1, 2011 at 6:44 PM, Costello, Roger L.
Hi Folks,
When I say:
"Let x be of datatype Int."
I think the proper terminology is "bind". That is, I bind the name "x" to the Int datatype.
Is that the correct terminology?
When someone uses the terminology "bind" I assume that they are referring to binding a value to a name, not associating a typing rule with the name. So in the haskell declaration:
let f x = show x
I would use the word "binding" to refer to the introduction of the variable named "x" as used in the body of the function "f". That might be an over-limited view of the concept, and really this only applies to to the study of the structure of programming languages themselves - I feel like you might be talking about something different. I don't quite understanding what you're after in the rest of the post. Are you implementing a compiler? Some sort of abstract analysis work? What is your "DataType" type meant to represent? What is your "Element" type meant to represent? Antoine
participants (2)
-
Antoine Latter
-
Costello, Roger L.