@Araq thanks, seems to be a tricky bug indeed :).

Do you know if there's a workaround? Can you please take a look at this 
example, would it be possible to implement it? About the example - in one file 
the generic crawler is defined, and in another file the specific `process` proc 
to handle specific crawling task.

Executable version, hit "Run" 
<https://repl.it/@alexeypetrushin/how-to-create-crawler#main.nim>

crawler.nim file
    
    
    import json
    
    type
      Job* = object of RootObj
        id*:   string
      
      Processed* = object
        result: string
      
      Crawler*[J] = object
        jobs*: seq[J]
    
    proc run*[J: Job](crawler: Crawler[J]): void =
      var processed: seq[Processed] = @[]
      for job in crawler.jobs:
        let result: string = job.process()
        processed.add Processed(result: result)
      
      echo %(processed)
    
    
    Run

main.nim file
    
    
    import crawler
    
    type GetPriceJob = object of Job
      symbol: string
    
    proc process*(job: GetPriceJob): string = "Price for " & job.symbol & " = 
500 USD"
    
    Crawler[GetPriceJob](
      jobs: @[
        GetPriceJob(symbol: "MSFT")
      ]
    ).run()
    
    
    Run

Reply via email to