Permalink
Browse files

First version of HaskellKoans with basic setup for parser combinators

  • Loading branch information...
0 parents commit e65555486fa4208e586c19687ab6d397526c615e @roman roman committed Jan 9, 2012
Showing with 133 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +81 −0 HaskellKoans.cabal
  3. 0 LICENSE
  4. +2 −0 Setup.hs
  5. +4 −0 bin/parserc-koans
  6. +6 −0 bin/setup-koans
  7. +22 −0 test/ParserCombinators.hs
  8. +16 −0 test/TestSuite.hs
@@ -0,0 +1,2 @@
+cabal-dev/*
+dist/*
@@ -0,0 +1,81 @@
+-- HackNight.cabal auto-generated by cabal init. For additional
+-- options, see
+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
+-- The name of the package.
+Name: HaskellKoans
+
+-- The package version. See the Haskell package versioning policy
+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
+-- standards guiding when and how versions should be incremented.
+Version: 0.1
+
+-- A short (one-line) description of the package.
+Synopsis: Haskell Koans
+
+-- A longer description of the package.
+-- Description:
+
+-- The license under which the package is released.
+License: MIT
+
+-- The file containing the license text.
+License-file: LICENSE
+
+-- The package author(s).
+Author: Roman Gonzalez, Ujihisa
+
+-- An email address to which users can send suggestions, bug reports,
+-- and patches.
+Maintainer: romanandreg@gmail.com
+
+-- A copyright notice.
+-- Copyright:
+
+Category: Learning
+
+Build-type: Simple
+
+-- Extra files to be distributed with the package, such as examples or
+-- a README.
+-- Extra-source-files:
+
+-- Constraint on the version of Cabal needed to build this package.
+Cabal-version: >=1.2
+
+--Test-Suite koans
+-- Type: exitcode-stdio-1.0
+--
+-- Main-is:
+-- TestSuite.hs
+--
+-- HS-source-dirs:
+-- test
+--
+-- Build-depends:
+-- base <= 5,
+-- attoparsec,
+-- HUnit,
+-- test-framework,
+-- test-framework-hunit
+
+Executable koans
+ -- .hs or .lhs file containing the Main module.
+ Main-is:
+ TestSuite.hs
+
+ -- Packages needed in order to build this package.
+ Build-depends:
+ base <= 5,
+ attoparsec,
+ HUnit,
+ test-framework,
+ test-framework-hunit
+
+ HS-source-dirs:
+ test
+ -- Modules not exported by this package.
+ -- Other-modules:
+
+ -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
+ -- Build-tools:
+
No changes.
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cabal-dev build && ./dist/build/koans/koans -t "ParserCombinators"
+
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+cabal install cabal-dev &&
+cabal-dev install --only-dependencies &&
+cabal-dev configure
+
@@ -0,0 +1,22 @@
+{-# LANGUAGE OverloadedStrings #-}
+module ParserCombinators (tests) where
+
+import Test.Framework (Test)
+import Test.Framework.Providers.HUnit (testCase)
+import Test.HUnit (assertBool, assertEqual)
+import qualified Data.Attoparsec.Text as P
+
+put_parser_here = undefined
+
+tests :: [Test]
+tests =
+ [
+ testDigitParser
+ ]
+
+testDigitParser :: Test
+testDigitParser = testCase "digit parser" $ do
+ let result = P.parseOnly put_parser_here "5"
+ case result of
+ Left e -> assertBool e False
+ Right answer -> assertEqual "wrong parser" "5" answer
@@ -0,0 +1,16 @@
+module Main (main) where
+
+import Test.Framework (Test, defaultMain, testGroup)
+import Test.Framework.Providers.HUnit (testCase)
+import Test.HUnit (assertBool)
+
+import qualified ParserCombinators
+
+main :: IO ()
+main = defaultMain tests
+ where
+ tests =
+ [
+ testGroup "ParserCombinators" ParserCombinators.tests
+ ]
+

0 comments on commit e655554

Please sign in to comment.