run :: [Genome] -> Socket -> IO [Genome]
run genomes sock = do
  let ntodo = length genomes
  ndone <- newMVar 0
  todo <- newChan :: IO (Chan Genome)
  done <- newChan :: IO (Chan Genome)
  writeList2Chan todo genomes
  sender ntodo ndone todo done sock
  readNextN done ntodo


{- ntodo is the number of genomes to be evaluated and should not change
- ndone is the number of genomes completed can goes from 0 to ntodo
- todo is a channel containing all the genomes yet to be done
- done is a channel containing all the genomes completed
-}
run :: [Genome] -> Socket -> IO [Genome]
run genomes sock = do
  let ntodo = length genomes
  ndone <- newMVar 0
  todo <- newChan :: IO (Chan Genome)
  done <- newChan :: IO (Chan Genome)
  writeList2Chan todo genomes
  sender ntodo ndone todo done sock
  readNextN done ntodo


{- ntodo is the number of genomes to be evaluated and should not change
- ndone is the number of genomes completed can goes from 0 to ntodo
- todo is a channel containing all the genomes yet to be done
- done is a channel containing all the genomes completed
-}
run genomes sock = do
  let ntodo = length genomes
  ndone <- newMVar 0
  todo <- newChan :: IO (Chan Genome)
  done <- newChan :: IO (Chan Genome)
  writeList2Chan todo genomes
  sender ntodo ndone todo done sock
  readNextN done ntodo


{- ntodo is the number of genomes to be evaluated and should not change
- ndone is the number of genomes completed can goes from 0 to ntodo
- todo is a channel containing all the genomes yet to be done
- done is a channel containing all the genomes completed
-}