
2 Jul
2013
2 Jul
'13
9:25 a.m.
On Tue, Jul 02, 2013 at 03:03:08PM +0200, Vlatko Basic wrote:
Is there a nicer way to extract the 'IO String' from 'IOS', without 'case' or without pattern matching the whole 'P'?
newtype IOS = IOS (IO String) data P = P { getA :: String, getB :: String, getC :: IOS } deriving (Show, Eq)
getC_IO :: P -> IO String getC_IO p = case getC p of IOS a -> a getC_IO (P _ _ (IOS a)) = a
How about unIOS :: IOS -> IO String unIOS (IOS a) = a getC_IO :: P -> IO String getC_IO = unIOS . getC Tom