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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe