Question: I'm writing a custom module for one of my projects and I'm having a bit of an issue. What I'm trying to do is get a piece of data from uc\_cart\_get\_contents() into a variable so that I can use it in a calculation: 

Here's my var\_export:

```
array ( )array ( 0 => stdClass::__set_state(array( 'cart_item_id' => '5', 'cart_id' => '1', 'nid' => '9', 'qty' => '10', 'changed' => '1287074120', 'data' => array ( 'attributes' => array ( 3 => '4', ), 'shippable' => '1', 'restrict_qty' => '0', 'module' => 'uc_product', ), 'title' => 'Chicago Canyon', 'vid' => '9', 'cost' => 1.16, 'price' => 11.16, 'weight' => 0, 'module' => 'uc_product', 'model' => 'chicago-canyon-p-card-p-env', )), )

```

But what if I want to put the model of each item in the cart into a variable, and based upon that variable adjust the item's price.

If it was an array I would do this:

```
$items= uc_cart_get_contents();

$model = $items[model];

```

but that doesn't work, it's a std class. I'm so so lost. Please help!

Answer: 
From: <http://www.haskell.org/tutorial/classes.html>

> 
> Before going on to further examples of the use of type classes, it is worth pointing out two other views of Haskell's type classes. The first is by analogy with object-oriented programming (OOP). In the following general statement about OOP, simply substituting type class for class, and type for object, yields a valid summary of Haskell's type class mechanism:
> 
> 
> "Classes capture common sets of operations. A particular object may be an instance of a class, and will have a method corresponding to each operation. Classes may be arranged hierarchically, forming notions of superclasses and sub classes, and permitting inheritance of operations/methods. A default method may also be associated with an operation."
> 
> 
> In contrast to OOP, it should be clear that types are not objects, and in particular there is no notion of an object's or type's internal mutable state. An advantage over some OOP languages is that methods in Haskell are completely type-safe: any attempt to apply a method to a value whose type is not in the required class will be detected at compile time instead of at runtime. In other words, methods are not "looked up" at runtime but are simply passed as higher-order functions.
> 
> 
>
This slideshow may help you understand the similarities and differences between OO abstract classes and Haskell type classes: [Classes, Jim, But Not As We Know Them](http://www.springerlink.com/index/77607141463259g4.pdf).