
Why is code in postings so often mangled: Subject: [Haskell-cafe] ContT and MonadSafe ... Then I implement this kind of method withHdf5PathP :: (MonadSafe m, Location l) => l -> Hdf5Path sh e -> (Dataset -> m r) -> m r withHdf5PathP loc (H5RootPath subpath) f = withHdf5PathP loc subpath f withHdf5PathP loc (H5GroupPath n subpath) f = withGroupP (openGroup loc n Nothing) $ \g -> withHdf5PathP g subpath f withHdf5PathP loc (H5GroupAtPath i subpath) f = withGroupAtP loc i $ \g -> withHdf5PathP g subpath f withHdf5PathP loc (H5DatasetPath n) f = withDatasetP (openDataset' loc n Nothing) f withHdf5PathP loc (H5DatasetPathAttr (a, c)) f = withDatasetP (openDatasetWithAttr loc a c) f withHdf5PathP loc (H5Or l r) f = withHdf5PathP loc l f `catchAll` const (withHdf5PathP loc r f) I decided to switch to the ContT transfomer and try to implement this like this withHdf5PathP :: (MonadSafe m, Location l) => l -> Hdf5Path sh e -> ContT r m Dataset withHdf5PathP loc (H5RootPath subpath) = withHdf5PathP loc subpath withHdf5PathP loc (H5GroupPath n subpath) = do g <- withGroupP (openGroup loc n Nothing) withHdf5PathP g subpath withHdf5PathP loc (H5GroupAtPath i subpath) = do g <- withGroupAtP loc i withHdf5PathP g subpath withHdf5PathP loc (H5DatasetPath n) = withDatasetP (openDataset' loc n Nothing) withHdf5PathP loc (H5DatasetPathAttr (a, c)) = withDatasetP (openDatasetWithAttr loc a c) withHdf5PathP loc (H5Or l r) = ???
participants (2)
-
Branimir Maksimovic
-
Gregory Guthrie