Browse Source

Initialized Haskell Project

master
commit
6837e5b077
  1. 5
      .gitignore
  2. 37
      Hml.cabal
  3. 0
      LICENSE
  4. 2
      Setup.hs
  5. 10
      src/Hml.hs
  6. 22
      test/Hml/Test.hs
  7. 7
      test/test.hs

5
.gitignore

@ -0,0 +1,5 @@
.cabal-sandbox
cabal.sandbox.config
dist
*.swp
*~

37
Hml.cabal

@ -0,0 +1,37 @@
-- Initial Hml.cabal generated by cabal init. For further documentation,
-- see http://haskell.org/cabal/users-guide/
name: Hml
version: 0.1.0.0
synopsis: Machine Learning Library
-- description:
homepage: http://github.com/yogsototh/Hml
license: PublicDomain
license-file: LICENSE
author: Yann Esposito
maintainer: Yann.Esposito@gmail.com
-- copyright:
category: Machine Learning
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
exposed-modules: Hml
-- other-modules:
-- other-extensions:
build-depends: base >=4.6 && <4.7
hs-source-dirs: src
default-language: Haskell2010
test-suite Tests
hs-source-dirs: test
main-is: test.hs
Type: exitcode-stdio-1.0
build-depends: base ==4.6.*, Cabal >= 1.16.0
, Hml
, QuickCheck
, HUnit
, test-framework
, test-framework-hunit
, test-framework-quickcheck2

0
LICENSE

2
Setup.hs

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

10
src/Hml.hs

@ -0,0 +1,10 @@
-- | The Hml module
module Hml
where
-- | A data set is mostly a list of data
type Dataset = [Integer]
-- | Cost function return the cost of some hypothesis relatively to some data
cost :: Dataset -> Integer
cost ds = sum ds

22
test/Hml/Test.hs

@ -0,0 +1,22 @@
module Hml.Test where
import Test.Framework (testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)
import Test.Framework.Providers.QuickCheck2 (testProperty)
import Hml
hmlSuite :: Test
hmlSuite = testGroup "Hml testing"
[ testCase "Linear Cost Function" (testCost linearDataset 100)
, testProperty "Cost Function QuickCheck" prop_cost]
linearDataset = [10,20,30,40]
testCost :: Dataset -> Integer -> Assertion
testCost ds expectedValue = expectedValue @=? cost ds
prop_cost :: [Integer] -> Bool
prop_cost list = sum list == cost list

7
test/test.hs

@ -0,0 +1,7 @@
module Main where
import Test.Framework (defaultMain)
import Hml.Test
main :: IO ()
main = defaultMain [hmlSuite]
Loading…
Cancel
Save