You could always just put it into your newtype: newtype IOS = IOS { unIOS :: IO String }
On Tue, Jul 2, 2013 at 9:31 AM, Vlatko Basic <vlatko.ba...@gmail.com> wrote: > > > -------- Original Message -------- > Subject: Re: [Haskell-cafe] "Casting" newtype to base type? > From: Tom Ellis <tom-lists-haskell-cafe-2...@jaguarpaw.co.uk> > To: haskell-cafe@haskell.org > Date: 02.07.2013 15:25 > >> 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 >> > Thanks for your answer. > I had those two funcs, but thought there might be a shorter/prettier > one-func one-liner. :-) > > >> Tom >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe