Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Stefan Holdermans
Martin, importFile :: Editor - String - IO () importFile ed path = do s - readFile path ps - mapM (\x - makePair (x, )) (lines s) es - return $ V.fromList ps writeIORef ed es loadFile :: Editor - String - IO () loadFile ed path = do s - readFile path ps - mapM makePair

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Martin DeMello
On Tue, Nov 29, 2011 at 12:35 AM, Stefan Holdermans ste...@vectorfabrics.com wrote: Have you considered abstracting over the bits in which importFile and loadFile differ? For example:  processFile :: (String - IO [PairBox]) - Editor - String - IO ()  processFile f ed path = do    s -

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Stefan Holdermans
Martin, (The trick with `flip` is tempting, but again at the cost of having to peer rather too closely at the implementation of processFile when reading the code). That trick is of course completely orthogonal. One could just as well write: processFile :: (String - [a]) - (a - (String,

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Martin DeMello
On Tue, Nov 29, 2011 at 12:55 AM, Stefan Holdermans ste...@vectorfabrics.com wrote: Martin, (The trick with `flip` is tempting, but again at the cost of having to peer rather too closely at the implementation of processFile when reading the code). That trick is of course completely

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Holger Siegel
Am 29.11.2011 um 09:16 schrieb Martin DeMello: I have the following functions: makePair :: (String, String) - IO PairBox parseFile :: String - [(String, String)] importFile :: Editor - String - IO () importFile ed path = do s - readFile path ps - mapM (\x - makePair (x, )) (lines

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Stefan Holdermans
Martin, Quick question: what's the difference between importFile ed = readfile = fromRawFile = setEditor ed and importFile = readfile = fromRawFile = setEditor that the former compiles but the latter doesn't? Note that, in Haskell, function application has higher priority then any

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Vo Minh Thu
2011/11/29 Stefan Holdermans ste...@vectorfabrics.com: Martin, (The trick with `flip` is tempting, but again at the cost of having to peer rather too closely at the implementation of processFile when reading the code). That trick is of course completely orthogonal. One could just as well