Skip to content

Commit 57fe378

Browse files
committed
included doctest
1 parent 01e297c commit 57fe378

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

Diff for: data-haskell-examples.cabal

+54
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,60 @@ library
7070
TypeFamilies,
7171
TypeOperators
7272

73+
test-suite data-haskell-examples-test
74+
type:
75+
exitcode-stdio-1.0
76+
default-language:
77+
Haskell2010
78+
ghc-options:
79+
-funbox-strict-fields
80+
-fforce-recomp
81+
-threaded
82+
-rtsopts
83+
-with-rtsopts=-N
84+
hs-source-dirs:
85+
test
86+
main-is:
87+
Spec.hs
88+
build-depends:
89+
base >= 4.7 && < 5,
90+
protolude,
91+
data-haskell-examples,
92+
doctest
93+
default-extensions:
94+
NoImplicitPrelude,
95+
UnicodeSyntax,
96+
BangPatterns,
97+
BinaryLiterals,
98+
DeriveFoldable,
99+
DeriveFunctor,
100+
DeriveGeneric,
101+
DeriveTraversable,
102+
DisambiguateRecordFields,
103+
EmptyCase,
104+
FlexibleContexts,
105+
FlexibleInstances,
106+
FunctionalDependencies,
107+
GADTSyntax,
108+
InstanceSigs,
109+
KindSignatures,
110+
LambdaCase,
111+
MonadComprehensions,
112+
MultiParamTypeClasses,
113+
MultiWayIf,
114+
NegativeLiterals,
115+
OverloadedStrings,
116+
ParallelListComp,
117+
PartialTypeSignatures,
118+
PatternSynonyms,
119+
RankNTypes,
120+
RecordWildCards,
121+
RecursiveDo,
122+
ScopedTypeVariables,
123+
TupleSections,
124+
TypeFamilies,
125+
TypeOperators
126+
73127
executable data-haskell-examples
74128
default-language:
75129
Haskell2010

Diff for: examples/examples.hs

+23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
12
import Protolude
23
import Data.Vector as V
34
import Numeric.LinearAlgebra as H
45

6+
-- |
7+
-- >>> let x = V.fromList [0..5]
8+
-- >>> V.length x
9+
-- 6
10+
--
11+
-- >>> V.null x
12+
-- False
13+
14+
-- | hmatrix examples
15+
-- >>> let x = (2><2) [0..3] :: Matrix Double
16+
-- >>> x
17+
-- (2><2)
18+
-- [ 0.0, 1.0
19+
-- , 2.0, 3.0 ]
20+
--
21+
-- Matrix multiplication
22+
-- >>> let y = fromLists [[0, 1], [2, 3]] :: Matrix Double
23+
-- >>> x H.<> y
24+
-- (2><2)
25+
-- [ 2.0, 3.0
26+
-- , 6.0, 11.0 ]
27+
528
main :: IO ()
629
main = do
730
-- vector examples

Diff for: test/Spec.hs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
2+
import Protolude
3+
import Test.DocTest
4+
5+
main :: IO ()
6+
main = doctest ["examples/examples.hs"]

0 commit comments

Comments
 (0)