test.gby

Similar documents
bdd.gby

fp.gby

haskell.gby

2

Copyright c 2008 Zhenjiang Hu, All Right Reserved.


monad.gby

2

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

3 3.1 algebraic datatype data k = 1 1,1... 1,n1 2 2,1... 2,n2... m m,1... m,nm 1 m m m,1,..., m,nm m 1, 2,..., k 1 data Foo x y = Alice x [y] B

org/ghc/ Windows Linux RPM 3.2 GHCi GHC gcc javac ghc GHCi(ghci) GHCi Prelude> GHCi :load file :l file :also file :a file :reload :r :type expr :t exp

第12回 モナドパーサ


kyoto.gby

第9回 型とクラス

Copyright c 2006 Zhenjiang Hu, All Right Reserved.

WEBサービス超入門 mask.key

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

新・明解Java入門

,,,,., C Java,,.,,.,., ,,.,, i

tuat1.dvi

連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) 文字列の分解 1 1 Haskell lines Prelude lines :: String -> [String] lines "" = [] lines s = let (l,s'

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

ohp02.dvi

listings-ext

Parametric Polymorphism

: gettoken(1) module P = Printf exception End_of_system (* *) let _ISTREAM = ref stdin let ch = ref ( ) let read () = (let c =!ch in ch := inp

Jacques Garrigue

橡ソート手順比較

VDM-SL VDM VDM-SL Toolbox VDM++ Toolbox 1 VDM-SL VDM++ Web bool

R R S S 6 S S D D S3 S3 R R S 6 S 6 S S D D w.o S3 S3 R5 3-0 R S 06 S 6 6 S S 6 D D 30 S3 w.o S3 R R8 7 3-

presen.gby

r08.dvi

K227 Java 2


() / (front end) (back end) (phase) (pass) 1 2

ohp08.dvi

Functional Programming

第10回 モジュール

r02.dvi

Functional Programming

Q&A集

/ , ,908 4,196 2, ,842 38, / / 2 33 /

Boo Boo 2 Boo 2.NET Framework SDK 2 Subversion 2 2 Java 4 NAnt 5 Boo 5 5 Boo if 11 for 11 range 12 break continue 13 pass

I 2 tutimura/ I 2 p.1/??

( ) ( ) lex LL(1) LL(1)

6 (1) app.html.eex 28 lib/nano_planner_web/templates/layout/app.html.eex 27 <footer> Oiax Inc <%= this_year() %> Oiax Inc. 29 </footer>

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

橡点検記録(集約).PDF

ex01.dvi

つくって学ぶプログラミング言語 RubyによるScheme処理系の実装

ML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1

untitled

tkk0408nari

Ruby Ruby ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( ) 44=>



16 (2) 23 - <div class="col-12 col-md-4"> </div> 23 + <div class="col-12 col-md-4 bg-info text-white text-md-right"> </div> HTML bg-info #17

2 objective m a ( ) Haskell Rank2Types 2 newtype Object f g = Object { runobject :: forall a. f a -> g (a, Object f g) } 1 a g a Functor g a ::

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

ALG ppt

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

ruby novice ruby novice ruby novice.

untitled

Agenda Motivation How it works Performance Limitation Conclusion

RX600 & RX200シリーズ アプリケーションノート RX用仮想EEPROM


fiš„v3.dvi

(pack ) Toplevel

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu

r03.dvi

Functional Programming

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

アルゴリズムとデータ構造1


ohp07.dvi

ohp03.dvi

102

明解Javaによるアルゴリズムとデータ構造

r1.dvi

AtCoder Regular Contest 073 Editorial Kohei Morita(yosupo) A: Shiritori if python3 a, b, c = input().split() if a[len(a)-1] == b[0] and b[len(

1st-session key

untitled

橡ボーダーライン.PDF

「プログラミング言語」 SICP 第4章 ~超言語的抽象~ その6

第8回 関数

ex01.dvi

parser.y 3. node.rb 4. CD-ROM

「Android Studioではじめる 簡単Androidアプリ開発」正誤表

com.ibm.etools.egl.jsfsearch.tutorial.doc.ps

Gartner Day

Condition DAQ condition condition 2 3 XML key value

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

2) TA Hercules CAA 5 [6], [7] CAA BOSS [8] 2. C II C. ( 1 ) C. ( 2 ). ( 3 ) 100. ( 4 ) () HTML NFS Hercules ( )

Javaで体験するスクリプト言語の威力

Java演習(4) -- 変数と型 --

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

5 IO Haskell return (>>=) Haskell Haskell Haskell 5.1 Util Util (Util: Tiny Imperative Language) 1 UtilErr, UtilST, UtilCont, Haskell C

(CC Attribution) Lisp 2.1 (Gauche )

Transcription:

Beautiful Programming Language and Beautiful Testing 1

Haskeller Haskeller 2

Haskeller (Doctest QuickCheck ) github 3

Haskeller 4

Haskell Platform 2011.4.0.0 Glasgow Haskell Compiler + 23 19 8 5 10 5

Q) Haskeller A) 6

Q) A) Haskell 7

Haskell 8

Haskell (+) :: Num a => a -> a -> a sort :: Ord a => [a] -> [a] delete :: Eq a => a -> [a] -> [a] hgetline :: Handle -> IO String writefile :: FilePath -> String -> IO () forkio :: IO () -> IO ThreadId 9

Haskell 10

Haskell Haskell 11

daemonize :: IO () -> IO () daemonize program = ensuredetachterminalcanwork $ do detachterminal ensureneverattachterminal $ do changeworkingdirectory "/" void $ setfilecreationmask 0 mapm_ closefd [stdinput, stdoutput, stderror] program where ensuredetachterminalcanwork p = do void $ forkprocess p exitsuccess ensureneverattachterminal p = do void $ forkprocess p exitsuccess detachterminal = void createsession IO 12

Haskell 13

Haskell 14

Haskell 15

0 16

Haskell Haskeller 17

18

Doctest Python def factorial(n): """Return the factorial of n, an exact integer >= 0. If the result is small enough to fit in an int, return an int. Else return a long. >>> [factorial(n) for n in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000L """ import math if not n >= 0: raise ValueError("n must be >= 0")... 19

Haskell Haddock 20

Haddock -- unlines is an inverse operation to lines. -- It joins lines, after appending a terminating -- newline to each. unlines :: [String] -> String unlines [] = [] unlines (l:ls) = l ++ \n : unlines ls Haddock HTML 21

">>>" >>> length [] 0 >>> writefile "tmpfile" "Hello" >>> readfile "tmpfile" "Hello" >>> 1 div 0 *** Exception: divide by zero 22

doctest 23

24

Hspec Ruby Rspec Haskell Hspec describe "sort" $ do it "sorts in the ascending order" $ sort [3,7,1,5,2] shouldbe [1,2,3,5,7] it "preserves a sorted list" $ sort [1,2,3,5,7] shouldbe [1,2,3,5,7] 25

Hspec xunit HUnit do exist <- doesfileexist "foo.txt" exist @?= True do ret <- try $ evaluate (1 div 0) ret @?= Left DivideByZero Hspec do exist <- doesfileexist "foo.txt" exist shouldbe True doesfileexist "foo.txt" shouldreturn True evaluate (1 div 0) shouldthrow anyarithexception 26

27

Haskell QuickCheck prop_doublesort :: [Int] -> Bool prop_doublesort xs = sort xs == sort (sort xs) > quickcheck prop_doublesort +++ OK, passed 100 tests. 28

7 1946 12 29

30

Haskeller 31

QuickCheck QuickCheck prop_model x xs = linearsearch x xs == binarysearch x xs ) 32

QuickCheck Doctest "prop>" prop> Data.Map.null empty == True prop> \xs -> sort xs == sort (sort (xs::[int])) hspec property it "maintains a sorted list" $ property $ \xs -> sort xs == sort (sort (xs::[int])) 33

34

API 35

Monoid Monoid Hspec shouldsatisfymonoidlaws :: (Eq a, Show a, Monoid a, Arbitrary a) => a -> Spec shouldsatisfymonoidlaws t = do describe "memepty" $ do it "is a left identity" $ property $ \x -> mempty <> x == x astypeof t it "is a right identity" $ property $ \x -> x <> mempty == x astypeof t describe "<>" $ do it "is associative" $ property $ \x y z -> (x <> y) <> z == x <> (y <> z) astypeof t Int Monoid spec = do describe "Maybe as a Monoid" $ do shouldsatisfymonoidlaws (undefined :: [Int]) 36

Doctest + + Hspec + + Haskeller 37