[Haskell-cafe] Oops in Haskell

Stefan Holdermans stefan at cs.uu.nl
Fri Jul 17 14:28:47 EDT 2009


Kashyap,

> Can someone please send me a working example based on the contents  
> posted in the URL below?

There's a small typo in the post: the definition of Proto should read

data Proto = Proto {a :: A, b :: B, c :: C}

The rest seems fine to me. (See below for an excerpt).

Cheers,

   Stefan

-------------------------------------------
import Data.Function (fix)
data A = A B C ; fa = A
data B = B A C ; fb = B
data C = C A B ; fc = C
userFunction = C
data Proto = Proto {a :: A, b :: B, c :: C}
proto = \self -> Proto {
   a = fa (b self) (c self),
   b = fb (a self) (c self),
   c = fc (a self) (b self)
}
customizedProto = \self -> proto self {
    c = userFunction (a self) (b self)
}
customizedABC = fix customizedProto


More information about the Haskell-Cafe mailing list