
8 Apr
2010
8 Apr
'10
3:42 p.m.
Hi I don't think there is a direct equivalence. You can make T an opaque type using a module where you do not export the constructor. However, you can't then pattern match on the type so you have to supply a destructor - here called unT. Any module that imports XYZ only sees the type T, the 'handmade' constructor makeT and the destructor unT: module XYZ ( T, -- this does not export the constructor unT makeT ) where data T = PrivateT Int deriving (Eq,Show) unT :: T -> Int unT (PrivateT i) = i -- Add any checking you want here... makeT :: Int -> T makeT i = PrivateT i