
27 Jul
2011
27 Jul
'11
2:58 a.m.
On Tue, Jul 26, 2011 at 11:14 PM, Alexander Solla
data OrderType = Market Size | Limit LimitPrice Expiration Size | Stop (Either Percent Price) newtype Sell = Sell OrderType newtype Buy = Buy OrderType newtype Order = Order (Either Buy Sell)
size :: Order -> Int size (Order (Left (Buy (Market s))) = s size (Order (Left (Buy (Limit _ _ s))) = s etc.
Aah, thank you - this is really neat. So now, I can write (for instance) an Eq instance for OrderType and use deriving (Eq) on the newtypes that wrap it, and my Order can be a concrete type, but still encapsulates all the different types of order. Thank you! Tim Thank you