[Haskell-beginners] How do I do inheritance in haskell?

Karl Voelker karl at karlv.net
Thu May 8 22:50:12 UTC 2014


On Thu, May 8, 2014, at 01:26 AM, Dimitri DeFigueiredo wrote:

Now, I have to convert this (if possible) into an OrderBook type. An
orderbook is basically two lists. One list of the orders placed by
people who want to buy, the "bids", and the other with the orders of
people who want to sell, the "asks". Each order specifies what price
should be paid and how many bitcoins to buy/sell (the volume).



There are more representations you could choose.



One example, if you want bids and asks to have the same type:



data OrderType = Bid | Ask

data Order = Order OrderType Price Volume



And if you don't want them to have the same type:



data BidType -- requires -XEmptyDataDecls

data AskType

data Order a = Order Price Volume

type Bid = Order BidType

type Ask = Order AskType



-Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140508/75fa9313/attachment-0001.html>


More information about the Beginners mailing list