init cntd.
This commit is contained in:
parent
e923db54f1
commit
17844b5921
@ -17,6 +17,11 @@ library
|
|||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
exposed-modules: Lib
|
exposed-modules: Lib
|
||||||
build-depends: base >= 4.7 && < 5
|
build-depends: base >= 4.7 && < 5
|
||||||
|
, conduit
|
||||||
|
, conduit-combinators
|
||||||
|
, conduit-extra
|
||||||
|
, resourcet
|
||||||
|
, text
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
executable geval-exe
|
executable geval-exe
|
||||||
@ -33,6 +38,7 @@ test-suite geval-test
|
|||||||
main-is: Spec.hs
|
main-is: Spec.hs
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, geval
|
, geval
|
||||||
|
, hspec
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
20
src/Lib.hs
20
src/Lib.hs
@ -2,6 +2,24 @@ module Lib
|
|||||||
( geval
|
( geval
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Data.Conduit
|
||||||
|
import Data.Conduit.Combinators as CC
|
||||||
|
import qualified Data.Conduit.Binary as CB
|
||||||
|
import qualified Data.Conduit.Text as CT
|
||||||
|
import Control.Monad.Trans.Resource
|
||||||
|
import qualified Data.Conduit.List as CL
|
||||||
|
import Data.Text
|
||||||
|
import Data.Text.Read as TR
|
||||||
|
|
||||||
geval :: String -> String -> IO (Double)
|
geval :: String -> String -> IO (Double)
|
||||||
geval expectedFilePath outFilePath = do
|
geval expectedFilePath outFilePath = do
|
||||||
return $ 3.14
|
runResourceT $
|
||||||
|
CB.sourceFile expectedFilePath
|
||||||
|
$$ CT.decode CT.utf8
|
||||||
|
=$= CT.lines
|
||||||
|
=$= CL.map TR.double
|
||||||
|
=$= CC.map getValue
|
||||||
|
=$ CC.sum
|
||||||
|
|
||||||
|
getValue :: Either String (Double, Text) -> Double
|
||||||
|
getValue (Right (x, _)) = x
|
||||||
|
@ -1,2 +1,9 @@
|
|||||||
|
import Test.Hspec
|
||||||
|
|
||||||
|
import Lib
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = putStrLn "Test suite not yet implemented"
|
main = hspec $ do
|
||||||
|
describe "mean square error" $ do
|
||||||
|
it "simple test" $ do
|
||||||
|
geval "test/mse-simple/mse-simple/test-A/expected.tsv" "test/mse-simple/mse-simple-solution/test-A/out.tsv" `shouldReturn` 1.118033988749
|
||||||
|
Loading…
Reference in New Issue
Block a user