lambdabot-trusted (empty) → 5.0
raw patch · 5 files changed
+134/−0 lines, 5 filesdep +QuickCheckdep +basedep +oeissetup-changed
Dependencies added: QuickCheck, base, oeis
Files
- LICENSE +22/−0
- Setup.hs +3/−0
- lambdabot-trusted.cabal +39/−0
- src/Lambdabot/Plugin/Haskell/Check/ShowQ.hs +52/−0
- src/Lambdabot/Plugin/Haskell/Eval/Trusted.hs +18/−0
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2003 Andrew J. Bromage+Portions Copyright (c) 2003 Shae Erisson, Sven M. Hallberg, Taylor Campbell+Portions Copyright (c) 2003-2006 Members of the AUTHORS file++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject+to the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+import Distribution.Simple+main = defaultMainWithHooks defaultUserHooks
+ lambdabot-trusted.cabal view
@@ -0,0 +1,39 @@+name: lambdabot-trusted+version: 5.0++license: GPL+license-file: LICENSE++author: Bertram Felgenhauer+maintainer: Bertram Felgenhauer <int-e@gmx.de>++category: Development, Web+synopsis: Lambdabot trusted code.+description: Lambdabot is an IRC bot written over several years by+ those on the #haskell IRC channel.+ .+ This small package provides functions used by+ the \@run command.++homepage: http://haskell.org/haskellwiki/Lambdabot++build-type: Simple+cabal-version: >= 1.8+tested-with: GHC == 7.6.3, GHC == 7.8.3++source-repository head+ type: git+ location: https://github.com/lambdabot/lambdabot.git++library+ hs-source-dirs: src+ ghc-options: -Wall+ -funbox-strict-fields++ exposed-modules: Lambdabot.Plugin.Haskell.Eval.Trusted++ other-modules: Lambdabot.Plugin.Haskell.Check.ShowQ++ build-depends: base >= 4.4 && < 5,+ oeis >= 0.3.1,+ QuickCheck >= 2
+ src/Lambdabot/Plugin/Haskell/Check/ShowQ.hs view
@@ -0,0 +1,52 @@+-- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html)+-- Copyright date and holder unknown.+module Lambdabot.Plugin.Haskell.Check.ShowQ (myquickcheck) where++import Data.List (group, intercalate, sort)+import System.IO.Unsafe (unsafePerformIO)+import Test.QuickCheck (numTests, quickCheckWithResult, stdArgs, Result(..), Testable)++myquickcheck :: Testable prop => prop -> String+myquickcheck = unsafePerformIO . myquickcheck'++myquickcheck' :: Testable prop => prop -> IO String+myquickcheck' a = tests a 0 []++tests :: (Testable prop) => prop -> Int -> [[String]] -> IO String+tests prop ntest stamps =+ do result <- quickCheckWithResult stdArgs prop+ case result of+ NoExpectedFailure{} -> done "Arguments exhausted after" (numTests result) stamps+ GaveUp{} -> done "Arguments exhausted after" (numTests result) stamps+ Success{} -> done "OK, passed" (numTests result) stamps+ Failure{} -> return $ "Falsifiable, after "+ ++ show ntest+ ++ " tests:\n"+ ++ reason result++done :: String -> Int -> [[String]] -> IO String+done mesg ntest stamps = return $ mesg ++ " " ++ show ntest ++ " tests" ++ table+ where+ table = display+ . map entry+ . reverse+ . sort+ . map pairLength+ . group+ . sort+ . filter (not . null)+ $ stamps++ display [] = "."+ display [x] = " (" ++ x ++ ")."+ display xs = '.' : unlines (map (++ ".") xs)++ pairLength :: [a] -> (Int, a)+ pairLength [] = (0, error "pairLength should never get an empty list")+ pairLength xss@(xs:_) = (length xss, xs)++ entry (n, xs) = percentage n ntest+ ++ intercalate ", " xs++ percentage n m = show ((100 * n) `div` m) ++ "%"+
+ src/Lambdabot/Plugin/Haskell/Eval/Trusted.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE Trustworthy #-}+module Lambdabot.Plugin.Haskell.Eval.Trusted+ ( module Math.OEIS+ , module Test.QuickCheck+ , module Lambdabot.Plugin.Haskell.Check.ShowQ+ , module Lambdabot.Plugin.Haskell.Eval.Trusted+ ) where++import Math.OEIS+import Lambdabot.Plugin.Haskell.Check.ShowQ+import Test.QuickCheck++describeSequence :: SequenceData -> Maybe String+describeSequence = fmap description . lookupSequence++newtype Mu f = In { out :: f (Mu f) }++newtype Rec a = InR { outR :: Rec a -> a }