试图在Haskell ..errors中运行代码

时间:2016-12-03 19:13:04

标签: haskell

我是haskell的新手,我正在尝试从https://www.fpcomplete.com/blog/2016/09/data-haskell运行haskell中的数据挖掘代码 但它根本不起作用....我甚至用这些导入尝试了下面的代码 import Control.Monad.Except import Control.Monad.State, 仍然不起作用。

{-# LANGUAGE TypeApplications, OverloadedStrings, OverloadedLabels,
  TypeOperators, DataKinds, FlexibleContexts #-}
import Labels.RunResourceT

main =
 runResourceT $
 httpSource "http://chrisdone.com/ontime.csv.zip" responseBody .|
 zipEntryConduit "ontime.csv" .|
 fromCsvConduit
   @("fl_date" := Day, "tail_num" := String)
   (set #downcase True csv) .|
 dropConduit 10 .|
 takeConduit 5 .>
 tableSink

这是错误

Prelude> :l haskell-tut
[1 of 1] Compiling Main             ( haskell-tut.hs, interpreted )

haskell-tut.hs:3:1: error:
    Failed to load interface for `Labels.RunResourceT'
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.

如果您有任何人可以提供使用的进口或模块,甚至如何使用它,我将不胜感激! 我甚至尝试过:

import Control.Monad.Except 
import Control.Monad.State

仍然是错误 试过这个:

{-# LANGUAGE TypeApplications, OverloadedStrings, OverloadedLabels, TypeOperators, DataKinds, FlexibleContexts #-}

import Labels.Explore

main =
 runResourceT $
 httpSource "http://chrisdone.com/ontime.csv.zip" responseBody .|
 zipEntryConduit "ontime.csv" .|
 fromCsvConduit
   @("fl_date" := Day, "tail_num" := String)
   (set #downcase True csv) .|
 dropConduit 10 .|
 takeConduit 5 .>
 tableSink

在Github存储库中建议不起作用! 错误是:

Prelude> :load haskell-tut
[1 of 1] Compiling Main             ( haskell-tut.hs, interpreted )

haskell-tut.hs:3:1: error:
    Failed to load interface for `Labels.Explore'
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.

尝试了整个Github代码:

{-# LANGUAGE TypeApplications, OverloadedStrings, OverloadedLabels,
  TypeOperators, DataKinds, FlexibleContexts #-}

import Labels.Explore

moo1 :: IO ()
moo1 =
  runResourceT $
  httpSource "http://chrisdone.com/ontime.csv.zip" responseBody .|
  zipEntryConduit "ontime.csv" .|
  fromCsvConduit
    @("fl_date" := Day, "tail_num" := String)
    (set #downcase True csv) .|
  dropConduit 10 .|
  takeConduit 5 .>
  tableSink

moo_write :: IO ()
moo_write =
  runResourceT
    (httpSource "http://chrisdone.com/ontime.csv.zip" responseBody .|
     zipEntryConduit "ontime.csv" .>
     fileSink "ontime.csv")

moo1_1 :: IO ()
moo1_1 =
  runResourceT $
  fileSource "ontime.csv" .|
  fromCsvConduit
    @("distance" := Double)
    (set #downcase True csv) .|
  sinkConduit
    (foldSink
       (\table row ->
          modify #flights (+ 1) (modify #distance (+ get #distance row) table))
       (#flights := (0 :: Int), #distance := 0)) .>
  tableSink

moo2 :: IO ()
moo2 =
  runResourceT $
  fileSource "ontime.csv" .|
  fromCsvConduit
    @("fl_date" := Day, "tail_num" := String, "airline_id" := Int, "unique_carrier" := String)
    (set #downcase True csv) .|
  groupConduit #airline_id .|
  explodeConduit .|
  projectConduit @("fl_date" := _, "unique_carrier" := _) .|
  takeConduit 5 .>
  tableSink

moo3 :: IO ()
moo3 =
  runResourceT $
  fileSource "ontime.csv" .|
  fromCsvConduit
    @("fl_date" := Day, "tail_num" := String, "airline_id" := Int, "unique_carrier" := String)
    (set #downcase True csv) .|
  groupConduit #airline_id .|
  explodeConduit .|
  dropConduit 10 .|
  projectConduit @("fl_date" := _, "tail_num" := _) .|
  takeConduit 5 .>
  tableSink

main = moo1_1

仍然收到以下错误!

Prelude> :load haskell-tut
[1 of 1] Compiling Main             ( haskell-tut.hs, interpreted )

haskell-tut.hs:4:1: error:
    Failed to load interface for `Labels.Explore'
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.

请帮忙!

0 个答案:

没有答案