on cf35b19 help sign in
.ghc.environment.x86_64-linux-8.6.5new file+17
since splitsnapshots
unifiedsplit
@@ -0,0 +1,17 @@
1+-- This is a GHC environment file written by cabal. This means you can
2+-- run ghc or ghci and get the environment of the project as a whole.
3+-- But you still need to use cabal repl $target to get the environment
4+-- of specific components (libs, exes, tests etc) because each one can
5+-- have its own source dirs, cpp flags etc.
6+--
7+clear-package-db
8+global-package-db
9+package-db /home/bolt/.cabal/store/ghc-8.6.5/package.db
10+package-db packagedb/ghc-8.6.5
11+package-id laop-0.1.0.0-inplace
12+package-id base-4.12.0.0
13+package-id ghc-prim-0.5.3
14+package-id rts
15+package-id integer-gmp-1.0.2.0
16+package-id deepseq-1.4.4.0
17+package-id array-0.5.3.0
.ghc.environment.x86_64-linux-8.8.3new file+17
@@ -0,0 +1,17 @@
1+-- This is a GHC environment file written by cabal. This means you can
2+-- run ghc or ghci and get the environment of the project as a whole.
3+-- But you still need to use cabal repl $target to get the environment
4+-- of specific components (libs, exes, tests etc) because each one can
5+-- have its own source dirs, cpp flags etc.
6+--
7+clear-package-db
8+global-package-db
9+package-db /home/bolt/.cabal/store/ghc-8.8.3/package.db
10+package-db dist-docs.Q1TJPL/packagedb/ghc-8.8.3
11+package-id laop-0.1.0.7-inplace
12+package-id base-4.13.0.0
13+package-id ghc-prim-0.5.3
14+package-id rts
15+package-id integer-gmp-1.0.2.0
16+package-id deepseq-1.4.4.0
17+package-id array-0.5.4.0
.github/workflows/ci.ymldeleted−43
@@ -1,43 +0,0 @@
1−name: CI
2−
3−# Trigger the workflow on push or pull request, but only for the master branch
4−on:
5− pull_request:
6− push:
7− branches: [master]
8−
9−jobs:
10− build:
11− name: ghc ${{ matrix.ghc }}
12− runs-on: ubuntu-16.04
13− strategy:
14− matrix:
15− cabal: ["3.0"]
16− ghc:
17− - "8.6.5"
18− - "8.8.3"
19−
20− steps:
21− - uses: actions/checkout@v2
22− if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
23−
24− - uses: actions/setup-haskell@v1
25− name: Setup Haskell
26− with:
27− ghc-version: ${{ matrix.ghc }}
28− cabal-version: ${{ matrix.cabal }}
29−
30− - uses: actions/cache@v1
31− name: Cache ~/.cabal/store
32− with:
33− path: ~/.cabal/store
34− key: ${{ runner.os }}-${{ matrix.ghc }}-cabal
35−
36− - name: Build
37− run: |
38− cabal v2-update
39− cabal v2-build --enable-tests --enable-benchmarks
40−
41− - name: Test
42− run: |
43− cabal v2-test --enable-tests
.gitignore+2−54
@@ -1,55 +1,3 @@
1−### Haskell
2−dist
3−dist-*
4−cabal-dev
5−*.o
6−*.hi
7−*.chi
8−*.chs.h
9−*.dyn_o
10−*.dyn_hi
11−*.prof
12−*.aux
13−*.hp
14−*.eventlog
15−.virtualenv
16−.hsenv
17−.hpc
18−.cabal-sandbox/
19−cabal.sandbox.config
20−cabal.config
21−cabal.project.local
22−.ghc.environment.*
23−.HTF/
24−# Stack
25.stack-work/
1.stack-work/
26−stack.yaml.lock
2+laop.cabal
27−
28−### IDE/support
29−# Vim
30−[._]*.s[a-v][a-z]
31−[._]*.sw[a-p]
32−[._]s[a-v][a-z]
33−[._]sw[a-p]
34−*~
3+*~
35−tags
36−
37−# IntellijIDEA
38−.idea/
39−.ideaHaskellLib/
40−*.iml
41−
42−# Atom
43−.haskell-ghc-mod.json
44−
45−# VS
46−.vscode/
47−
48−# Emacs
49−*#
50−.dir-locals.el
51−TAGS
52−
53−# other
54−.DS_Store
55−hackage.sh
.travis.ymldeleted−47
@@ -1,47 +0,0 @@
1−sudo: true
2−language: haskell
3−
4−git:
5− depth: 5
6−
7−cabal: "3.0"
8−
9−cache:
10− directories:
11− - "$HOME/.cabal/store"
12− - "$HOME/.stack"
13− - "$TRAVIS_BUILD_DIR/.stack-work"
14−
15−matrix:
16− include:
17− - ghc: 8.6.5
18− - ghc: 8.8.3
19−
20− - ghc: 8.8.3
21− env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.8.3.yaml"
22−
23− - ghc: 8.6.5
24− env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"
25−
26−
27−install:
28− - |
29− if [ -z "$STACK_YAML" ]; then
30− cabal v2-update
31− cabal v2-build --enable-tests --enable-benchmarks
32− else
33− curl -sSL https://get.haskellstack.org/ | sh
34− stack --version
35− stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
36− fi
37−
38−script:
39− - |
40− if [ -z "$STACK_YAML" ]; then
41− cabal v2-test --enable-tests
42− else
43− stack test --system-ghc
44− fi
45−
46−notifications:
47− email: false
CHANGELOG.mddeleted−17
@@ -1,17 +0,0 @@
1−# Changelog
2−
3−`laop` uses [PVP Versioning][1].
4−The changelog is available [on GitHub][2].
5−
6−## 0.1.1.1
7−
8−* Bump base version to work with cabal
9−
10−## 0.1.1.0
11−
12−* Package is more organized and now has tests and benchmarks separated
13−* Repository is more organized and clean
14−* Added CI
15−
16−[1]: https://pvp.haskell.org
17−[2]: https://github.com/bolt12/laop2/releases
ChangeLog.mdnew file+3
@@ -0,0 +1,3 @@
1+# Changelog for laop
2+
3+## Unreleased changes
LICENSE+26−17
@@ -1,21 +1,30 @@
1−MIT License
1+Copyright Armando Santos (c) 2019
2
2
3−Copyright (c) 2020 Armando Santos
3+All rights reserved.
4
4
5−Permission is hereby granted, free of charge, to any person obtaining a copy
5+Redistribution and use in source and binary forms, with or without
6−of this software and associated documentation files (the "Software"), to deal
7−in the Software without restriction, including without limitation the rights
8−to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9−copies of the Software, and to permit persons to whom the Software is
10−furnished to do so, subject to the following conditions:
6+modification, are permitted provided that the following conditions are met:
11
7
12−The above copyright notice and this permission notice shall be included in all
8+ * Redistributions of source code must retain the above copyright
13−copies or substantial portions of the Software.
9+ notice, this list of conditions and the following disclaimer.
14
10
15−THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of Armando Santos nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16−IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17−FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18−AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19−LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20−OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21−SOFTWARE.
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md+29−33
@@ -1,11 +1,5 @@
1# laop - Linear Algebra of Programming library
1# laop - Linear Algebra of Programming library
2
2
3−[![GitHub CI](https://github.com/bolt12/laop/workflows/CI/badge.svg)](https://github.com/bolt12/laop/actions)
4−[![Build status](https://img.shields.io/travis/bolt12/laop.svg?logo=travis)](https://travis-ci.org/bolt12/laop)
5−[![Hackage](https://img.shields.io/hackage/v/laop.svg?logo=haskell)](https://hackage.haskell.org/package/laop)
6−[![Stackage Lts](http://stackage.org/package/laop/badge/lts)](http://stackage.org/lts/package/laop)
7−[![Stackage Nightly](http://stackage.org/package/laop/badge/nightly)](http://stackage.org/nightly/package/laop)
8−
9The LAoP discipline generalises relations and functions treating them as
3The LAoP discipline generalises relations and functions treating them as
10Boolean matrices and in turn consider these as arrows.
4Boolean matrices and in turn consider these as arrows.
11
5
@@ -16,38 +10,40 @@ motivation behind the library, the underlying theory, and implementation details
16This module offers many of the combinators mentioned in the work of
10This module offers many of the combinators mentioned in the work of
17[Macedo (2012)](https://repositorium.sdum.uminho.pt/handle/1822/22894) and [Oliveira (2012)](https://pdfs.semanticscholar.org/ccf5/27fa9179081223bffe8067edd81948644fc0.pdf).
11[Macedo (2012)](https://repositorium.sdum.uminho.pt/handle/1822/22894) and [Oliveira (2012)](https://pdfs.semanticscholar.org/ccf5/27fa9179081223bffe8067edd81948644fc0.pdf).
18
12
19−See the package in hackage [here](https://hackage.haskell.org/package/laop-0.1.1.0)
13+See the package in hackage [here](https://hackage.haskell.org/package/laop-0.1.0.5)
14+
15+There are a couple of repos with a WIP of benchmarks comparing [matrix composition](https://github.com/bolt12/laop-benchmarks) and a real use case of [data analytics](https://github.com/bolt12/laop-analytics).
20
16
21A Functional Pearl has been written and can be regarded as the [reference document](https://github.com/bolt12/tymfgg-pearl) for this library.
17A Functional Pearl has been written and can be regarded as the [reference document](https://github.com/bolt12/tymfgg-pearl) for this library.
22
18
23## Features
19## Features
24
20
25−This library offers 3 main matrix programming modules:
21+This library offers:
26−
22+
27−- One in which matrices are typed with type level natural numbers;
23+- An internal module representation that uses normal datatypes (`Void`, `()`, `Either`) for matrix dimensions and two
28−- One in which matrices are typed with arbitrary generic data types;
24+ type families `FromNat` and `Count` to make it easier to work with these type of matrices.
29−- One in which matrices are regarded as relations, i.e. boolean matrices;
25+- An interfacing module that uses generalised types for the dimensions and is just a newtype wrapper
30−
26+ around the internal matrix data type.
31−There's also an experimental module that uses matrices to represent probability
27+- An interfacing module that uses type level naturals for the dimensions and is just a newtype wrapper
32−distributions.
28+ around the internal matrix data type.
33−
29+- An interfacing module that restricts the matrix contents to being only 0's or 1's (True
34−The most interesting feature is that matrices are represented as an inductive data type.
30+ and False). This module is called 'Relation' and offers many of the combinators seen in
35−Given this formulation, matrix algorithms can be expressed in a much more elegant and
31+ AoP and Relational Calculus/Algebra.
36−calculational style than the traditional vector of vectors representation. This data type
32+- A very simple Probabilistic Programming module and several functions and data types to
37−guarantees that a matrix will always have valid dimensions. It can also express block matrix
33+ make it easier to deal with sample space.
38−computations naturally, which leads to total, efficient and statically typed manipulation
34+
39−and transformation functions.
35+Given this, this new matrix formulation compared to other libraries one has much more advantages, such as:
40−
36+
41−Like matrix multiplication, other common operations, such as matrix transposition, benefit from a block-oriented structure that leads to a simple and natural divide-and-conquer algorithmic solution. Performance wise, this means that without much effort we can obtain optimal cache-oblivious algorithms.
37+- Has an inductive definition enabling writing matrix manipulation functions in a much more elegant and calculational way;
42−
38+- Statically typed dimensions;
43−Given this, this new matrix formulation compared to other libraries:
39+- Polymorphic data type dimensions;
44−
40+- Polymorphic matrix content;
45−- Is more compositional and polymorphic and does not have partial matrix manipulation functions (hence less chances for usage errors);
41+- Awesome dimension type inference;
46−- Our implementation of matrices enables simple manipulation of submatrices, making it particularly suitable for formal verification and equation reasoning, using the mathematical framework defined by the linear algebra of programming. Furthermore, the data type constructors ensure that the matrices of this kind are sound, i.e. malformed matrices with incorrect dimensions of the sort, can not be constructed.
42+- Fast type natural conversion via `FromNat` type family;
47−
43+- Matrix `Junc` and `Split`-ing in O(1);
48−## Known issues
44+- Matrix composition takes advantage of divide-and-conquer and fusion laws.
49−
45+
50−Unfortunately, due to the use of type-level programming features, this approach sometimes requires type dimensions to be constrainted, in some way, impossible to write idiomatic Arrow instances, for example. Type inference isn't perfect, when it comes to infer the types of matrices which dimensions are computed using type level naturals multiplication, the compiler needs type annotations in order to succeed. And not all kinds of programs can be modeled using matrices, namely programs that deal with arbitrary infinite data types such as lists or integers (although there are some workarounds).
46+Unfortunately, this approach does not solve the issue of type dimensions being in some way constrainted making it impossible to write Arrow instances, for example. Type inference isn't perfect, when it comes to infer the types of matrices which dimensions are computed using type level naturals multiplication, the compiler needs type annotations in order to succeed.
51
47
52## Notes
48## Notes
53
49
Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
benchmark/Main.hs → app/Benchmarks.hsrenamed+6−3
@@ -8,7 +8,10 @@
8{-# LANGUAGE AllowAmbiguousTypes #-}
8{-# LANGUAGE AllowAmbiguousTypes #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10
10
11+module Benchmarks
12+ ( benchmark
13+ )
11−module Main (main) where
14+ where
12
15
13import LAoP.Dist.Internal
16import LAoP.Dist.Internal
14import LAoP.Utils
17import LAoP.Utils
@@ -144,8 +147,8 @@ setupEnv2 = do
144 distList2 <- generate (resize 1 (randomDistF @(Natural 0 100) @(Natural 0 100)))
147 distList2 <- generate (resize 1 (randomDistF @(Natural 0 100) @(Natural 0 100)))
145 return (m21, m40, dist, dist2, distList1, distList2)
148 return (m21, m40, dist, dist2, distList1, distList2)
146
149
147−main :: IO ()
150+benchmark :: IO ()
148−main = defaultMain [
151+benchmark = defaultMain [
149 env setupEnv $ \ ~(m11, m12, m21, m22, m31, m32) -> bgroup "Matrix Composition" [
152 env setupEnv $ \ ~(m11, m12, m21, m22, m31, m32) -> bgroup "Matrix Composition" [
150 bgroup "10x10" [
153 bgroup "10x10" [
151 bench "WHNF - 10x10" $ whnf (comp m11) m12
154 bench "WHNF - 10x10" $ whnf (comp m11) m12
test/Examples/Readme.hs → app/Examples.hsrenamed+2−1
@@ -1,10 +1,11 @@
1{-# LANGUAGE GADTs #-}
1{-# LANGUAGE GADTs #-}
2{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
4+{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE TypeApplications #-}
5{-# LANGUAGE TypeApplications #-}
5{-# LANGUAGE DataKinds #-}
6{-# LANGUAGE DataKinds #-}
6
7
7−module Examples.Readme
8+module Examples
8 ( exec
9 ( exec
9 )
10 )
10 where
11 where
app/Main.hsnew file+7
@@ -0,0 +1,7 @@
1+module Main where
2+
3+import Examples
4+import Benchmarks
5+
6+main :: IO ()
7+main = benchmark
test/Examples/Quantum.hs → app/Quantum.hsrenamed+2−2
@@ -1,5 +1,5 @@
1{-# LANGUAGE StandaloneDeriving #-}
1{-# LANGUAGE StandaloneDeriving #-}
2−module Examples.Quantum where
2+module Quantum where
3
3
4import LAoP.Utils
4import LAoP.Utils
5import LAoP.Matrix.Type
5import LAoP.Matrix.Type
@@ -21,7 +21,7 @@ cnot = kr fstM (fromF xor)
21ccnot :: (Num e, Ord e) => Matrix e ((Bool, Bool), Bool) ((Bool, Bool), Bool)
21ccnot :: (Num e, Ord e) => Matrix e ((Bool, Bool), Bool) ((Bool, Bool), Bool)
22ccnot = kr fstM (fromF f)
22ccnot = kr fstM (fromF f)
23 where
23 where
24− f = xor . tp (uncurry (&&)) id
24+ f = xor . (tp (uncurry (&&)) id)
25 tp f g (a,b) = (f a, g b)
25 tp f g (a,b) = (f a, g b)
26
26
27had :: Matrix (Complex Double) Bool Bool
27had :: Matrix (Complex Double) Bool Bool
test/Examples/Spreadsheets.hs → app/Spreadsheets.hsrenamed+2−1
@@ -1,6 +1,7 @@
1{-# LANGUAGE DeriveGeneric #-}
1{-# LANGUAGE DeriveGeneric #-}
2
2
3−module Examples.Spreadsheets
3+module Spreadsheets
4+ where
4
5
5import LAoP.Utils
6import LAoP.Utils
6import LAoP.Matrix.Type
7import LAoP.Matrix.Type
appveyor.ymldeleted−34
@@ -1,34 +0,0 @@
1−clone_folder: "c:\\WORK"
2−clone_depth: 5
3−
4−# Do not build feature branch with open Pull Requests
5−skip_branch_with_pr: true
6−
7−platform:
8− - x86_64
9−
10−cache:
11− - "C:\\SR"
12− - dist-newstyle
13−
14−environment:
15− global:
16− CABOPTS: --store-dir=C:\\SR
17−
18− matrix:
19− - GHCVER: 8.6.5
20−
21−install:
22− - choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
23− - choco install -y cabal --version 2.4.1.0
24− - choco install -y ghc --version 8.6.3
25− - refreshenv
26−
27−before_build:
28− - cabal --version
29− - ghc --version
30− - cabal %CABOPTS% v2-update
31−
32−build_script:
33− - cabal %CABOPTS% v2-build --enable-tests
34− - cabal %CABOPTS% v2-test --enable-tests
hackage.shnew file+10
@@ -0,0 +1,10 @@
1+#!/bin/sh
2+set -e
3+
4+dir=$(mktemp -d dist-docs.XXXXXX)
5+trap 'rm -r "$dir"' EXIT
6+
7+# assumes cabal 2.4 or later
8+cabal v2-haddock --builddir="$dir" --haddock-for-hackage --enable-doc
9+
10+cabal upload -d $dir/*-docs.tar.gz --publish
laop.cabal+72−82
@@ -1,89 +1,79 @@
1−cabal-version: 2.4
1+cabal-version: 1.12
2−name: laop
3−version: 0.1.1.1
4−synopsis: Matrix programming library
5−description: Matrix programming library that uses a type-safe inductive definition
6− inspired by the Linear Algebra of Programming
7−homepage: https://github.com/bolt12/laop
8−bug-reports: https://github.com/bolt12/laop/issues
9−license: MIT
10−license-file: LICENSE
11−author: Armando Santos
12−maintainer: Armando Santos <armandoifsantos@gmail.com>
13−copyright: 2020 Armando Santos
14−category: Data
15−build-type: Simple
16−extra-doc-files: README.md
17− CHANGELOG.md
18−tested-with: GHC == 8.6.5
19− GHC == 8.8.3
20
2
21−source-repository head
3+-- This file has been generated from package.yaml by hpack version 0.31.2.
22− type: git
4+--
23− location: https://github.com/bolt12/laop.git
5+-- see: https://github.com/sol/hpack
6+--
7+-- hash: c53e5ac8b0734f570fcea8d217d84e401323172c60a00eee9d60ffbaef505191
24
8
25−common common-options
9+name: laop
26− build-depends: base >= 4.12.0.0 && < 5,
10+version: 0.1.0.7
27− deepseq
11+description: Please see the README on GitHub at <https://github.com/xxxx/laop#readme>
28−
12+category: Data
29− ghc-options: -Wall
13+homepage: https://github.com/xxxx/laop#readme
30− -Wcompat
14+bug-reports: https://github.com/xxxx/laop/issues
31− -Widentities
15+author: Armando Santos
32− -Wincomplete-uni-patterns
16+maintainer: armandoifsantos@gmail.com
33− -Wincomplete-record-updates
17+copyright: MIT
34− if impl(ghc >= 8.0)
18+license: BSD3
35− ghc-options: -Wredundant-constraints
19+license-file: LICENSE
36− if impl(ghc >= 8.2)
20+build-type: Simple
37− ghc-options: -fhide-source-paths
21+extra-source-files:
38− if impl(ghc >= 8.4)
22+ README.md
39− ghc-options: -Wmissing-export-lists
23+ ChangeLog.md
40− -Wpartial-fields
41− if impl(ghc >= 8.8)
42− ghc-options: -Wmissing-deriving-strategies
43
24
44− default-language: Haskell2010
25+source-repository head
26+ type: git
27+ location: https://github.com/xxxx/laop
45
28
46library
29library
47− import: common-options
30+ exposed-modules:
31+ LAoP.Dist
32+ LAoP.Dist.Internal
33+ LAoP.Matrix.Internal
34+ LAoP.Matrix.Nat
35+ LAoP.Matrix.Type
36+ LAoP.Relation
37+ LAoP.Relation.Internal
38+ LAoP.Utils
39+ LAoP.Utils.Internal
40+ other-modules:
41+ Paths_laop
48− hs-source-dirs: src
42+ hs-source-dirs:
49− exposed-modules: LAoP.Dist
43+ src
50− LAoP.Dist.Internal
44+ build-depends:
51− LAoP.Matrix.Internal
45+ base >=4.7 && <5
52− LAoP.Matrix.Nat
46+ , deepseq
53− LAoP.Matrix.Type
47+ default-language: Haskell2010
54− LAoP.Relation
55− LAoP.Relation.Internal
56− LAoP.Utils
57− LAoP.Utils.Internal
58
48
59−test-suite laop-test
49+executable laop-exe
60− import: common-options
50+ main-is: Main.hs
61− type: exitcode-stdio-1.0
62− hs-source-dirs: test
63− other-modules: Examples.Readme
51+ other-modules:
64− main-is: Spec.hs
52+ Benchmarks
65− build-depends: laop
53+ Examples
66− ghc-options: -threaded
54+ Spreadsheets
67− -rtsopts
55+ Paths_laop
68− -with-rtsopts=-N
56+ hs-source-dirs:
69− -funfolding-use-threshold=16
57+ app
70− -fexcess-precision
58+ ghc-options: -threaded -rtsopts -with-rtsopts=-N2 -funfolding-use-threshold=16 -fexcess-precision -optc-O3 -optc-ffast-math
71− -optc-O3
59+ build-depends:
72− -optc-ffast-math
60+ QuickCheck
61+ , base >=4.7 && <5
62+ , criterion
63+ , deepseq
64+ , laop
65+ default-language: Haskell2010
73
66
74−benchmark laop-benchmark
67+test-suite laop-test
75− import: common-options
76− type: exitcode-stdio-1.0
68+ type: exitcode-stdio-1.0
69+ main-is: Spec.hs
70+ other-modules:
71+ Paths_laop
77− hs-source-dirs: benchmark
72+ hs-source-dirs:
78− main-is: Main.hs
73+ test
79− build-depends: criterion
80− , QuickCheck
81− , deepseq
82− , laop
83− ghc-options: -threaded
74+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
84− -rtsopts
75+ build-depends:
85− -with-rtsopts=-N
76+ base >=4.7 && <5
86− -funfolding-use-threshold=16
77+ , deepseq
87− -fexcess-precision
78+ , laop
88− -optc-O3
79+ default-language: Haskell2010
89− -optc-ffast-math
package.yamlnew file+57
@@ -0,0 +1,57 @@
1+name: laop
2+version: 0.1.0.7
3+github: "bolt12/laop"
4+license: BSD3
5+author: "Armando Santos"
6+maintainer: "armandoifsantos@gmail.com"
7+copyright: "MIT"
8+
9+extra-source-files:
10+- README.md
11+- ChangeLog.md
12+
13+# Metadata used when publishing your package
14+# synopsis: Short description of your package
15+category: Data
16+
17+# To avoid duplicated efforts in documentation and dealing with the
18+# complications of embedding Haddock markup inside cabal files, it is
19+# common to point users to the README.md file.
20+description: Please see the README on GitHub at <https://github.com/bolt12/laop#readme>
21+
22+dependencies:
23+- base >= 4.7 && < 5
24+- deepseq
25+
26+library:
27+ source-dirs: src
28+
29+executables:
30+ laop-exe:
31+ main: Main.hs
32+ source-dirs: app
33+ ghc-options:
34+ - -threaded
35+ - -rtsopts
36+ - -with-rtsopts=-N
37+ - -funfolding-use-threshold=16
38+ - -fexcess-precision # Good for doubles
39+ - -optc-O3 # Good for doubles
40+ - -optc-ffast-math # Good for doubles
41+ - -O2
42+ dependencies:
43+ - laop
44+ - criterion
45+ - deepseq
46+ - QuickCheck
47+
48+tests:
49+ laop-test:
50+ main: Spec.hs
51+ source-dirs: test
52+ ghc-options:
53+ - -threaded
54+ - -rtsopts
55+ - -with-rtsopts=-N
56+ dependencies:
57+ - laop
src/LAoP/Matrix/Internal.hs+18−21
@@ -789,38 +789,35 @@ corr p = let f = fromF' p :: Matrix e q ()
789
789
790-- Pretty print
790-- Pretty print
791
791
792−prettyAux :: Show e => [[e]] -> [[e]] -> String
792+fill :: Show e => [[e]] -> String -> String
793−prettyAux [] _ = ""
794−prettyAux [[e]] m = "│ " ++ fill (show e) ++ " │\n"
795− where
796− v = fmap show m
797− widest = maximum $ fmap length v
798− fill str = replicate (widest - length str - 2) ' ' ++ str
793+fill m str = replicate (widest - length str - 2) ' ' ++ str
799−prettyAux [h] m = "│ " ++ fill (unwords $ map show h) ++ " │\n"
800 where
794 where
801− v = fmap show m
795+ v = fmap show m
802− widest = maximum $ fmap length v
796+ widest = maximum $ fmap length v
797+
798+fill2 :: Show e => Matrix e cols rows -> String -> String
803− fill str = replicate (widest - length str - 2) ' ' ++ str
799+fill2 m str = replicate (widest - length str - 2) ' ' ++ str
804−prettyAux (h : t) l = "│ " ++ fill (unwords $ map show h) ++ " │\n" ++
805− prettyAux t l
806 where
800 where
807− v = fmap show l
801+ v = map show (toList m)
808− widest = maximum $ fmap length v
802+ widest = maximum $ map length v
809− fill str = replicate (widest - length str - 2) ' ' ++ str
803+
804+prettyAux :: Show e => [[e]] -> [[e]] -> String
805+prettyAux [] _ = ""
806+prettyAux [[e]] m = "│ " ++ fill m (show e) ++ " │\n"
807+prettyAux [h] m = "│ " ++ fill m (unwords $ map show h) ++ " │\n"
808+prettyAux (h : t) m = "│ " ++ fill m (unwords $ map show h) ++ " │\n" ++
809+ prettyAux t m
810
810
811-- | Matrix pretty printer
811-- | Matrix pretty printer
812pretty :: (CountableDims cols rows, Show e) => Matrix e cols rows -> String
812pretty :: (CountableDims cols rows, Show e) => Matrix e cols rows -> String
813pretty m = concat
813pretty m = concat
814 [ "┌ ", unwords (replicate (columns m) blank), " ┐\n"
814 [ "┌ ", unwords (replicate (columns m) blank), " ┐\n"
815 , unlines
815 , unlines
816− [ "│ " ++ unwords (fmap (\j -> fill $ show $ getElem i j m) [1..columns m]) ++ " │" | i <- [1..rows m] ]
816+ [ "│ " ++ unwords (fmap (\j -> fill2 m $ show $ getElem i j m) [1..columns m]) ++ " │" | i <- [1..rows m] ]
817 , "└ ", unwords (replicate (columns m) blank), " ┘"
817 , "└ ", unwords (replicate (columns m) blank), " ┘"
818 ]
818 ]
819 where
819 where
820− strings = map show (toList m)
821− widest = maximum $ map length strings
822− fill str = replicate (widest - length str) ' ' ++ str
823− blank = fill ""
820+ blank = fill2 m ""
824 safeGet i j m
821 safeGet i j m
825 | i > rows m || j > columns m || i < 1 || j < 1 = Nothing
822 | i > rows m || j > columns m || i < 1 || j < 1 = Nothing
826 | otherwise = Just $ unsafeGet i j m (toList m)
823 | otherwise = Just $ unsafeGet i j m (toList m)
stack-8.8.3.yamldeleted−1
@@ -1 +0,0 @@
1−resolver: lts-15.5
stack.yaml+66−1
@@ -1 +1,66 @@
1+# This file was automatically generated by 'stack init'
2+#
3+# Some commonly used options have been documented as comments in this file.
4+# For advanced use and comprehensive documentation of the format, please see:
5+# https://docs.haskellstack.org/en/stable/yaml_configuration/
6+
7+# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8+# A snapshot resolver dictates the compiler version and the set of packages
9+# to be used for project dependencies. For example:
10+#
11+# resolver: lts-3.5
12+# resolver: nightly-2015-09-21
13+# resolver: ghc-7.10.2
14+#
15+# The location of a snapshot can be provided as a file or url. Stack assumes
16+# a snapshot provided as a file might change, whereas a url resource does not.
17+#
18+# resolver: ./custom-snapshot.yaml
19+# resolver: https://example.com/snapshots/2018-01-01.yaml
1−resolver: lts-14.3
20+resolver: lts-14.18
21+
22+# User packages to be built.
23+# Various formats can be used as shown in the example below.
24+#
25+# packages:
26+# - some-directory
27+# - https://example.com/foo/bar/baz-0.0.2.tar.gz
28+# subdirs:
29+# - auto-update
30+# - wai
31+packages:
32+- .
33+# Dependency packages to be pulled from upstream that are not in the resolver.
34+# These entries can reference officially published versions as well as
35+# forks / in-progress versions pinned to a git hash. For example:
36+#
37+# extra-deps:
38+# - acme-missiles-0.3
39+# - git: https://github.com/commercialhaskell/stack.git
40+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
41+#
42+# extra-deps: []
43+
44+# Override default flag values for local packages and extra-deps
45+# flags: {}
46+
47+# Extra package databases containing global packages
48+# extra-package-dbs: []
49+
50+# Control whether we use the GHC we find on the path
51+# system-ghc: true
52+#
53+# Require a specific version of stack, using version ranges
54+# require-stack-version: -any # Default
55+# require-stack-version: ">=2.1"
56+#
57+# Override the architecture used by stack, especially useful on Windows
58+# arch: i386
59+# arch: x86_64
60+#
61+# Extra directories used by stack for building
62+# extra-include-dirs: [/path/to/dir]
63+# extra-lib-dirs: [/path/to/dir]
64+#
65+# Allow a newer minor version of GHC than the snapshot specifies
66+# compiler-check: newer-minor
stack.yaml.lock+4−4
@@ -6,7 +6,7 @@
6packages: []
6packages: []
7snapshots:
7snapshots:
8- completed:
8- completed:
9− size: 523878
9+ size: 524789
10− url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/3.yaml
10+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/18.yaml
11− sha256: 470c46c27746a48c7c50f829efc0cf00112787a7804ee4ac7a27754658f6d92c
11+ sha256: 646be71223e08234131c6989912e6011e01b9767bc447b6d466a35e14360bdf2
12− original: lts-14.3
12+ original: lts-14.18
test/Spec.hs+1−7
@@ -1,8 +1,2 @@
1−module Main (main) where
2−
3−import qualified Examples.Readme as RD
4−
5main :: IO ()
1main :: IO ()
6−main = do
2+main = putStrLn "Test suite not yet implemented"
7− putStrLn ("Testing if README works" :: String)
8− RD.exec