-
Notifications
You must be signed in to change notification settings - Fork 0
/
a794e5a60e125da72ff131485fb74ea90c987a78.patch
3370 lines (3353 loc) · 109 KB
/
a794e5a60e125da72ff131485fb74ea90c987a78.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/Carnap-Server/Application.hs b/Carnap-Server/Application.hs
index b0c27df..4ae6dae 100644
--- a/Carnap-Server/Application.hs
+++ b/Carnap-Server/Application.hs
@@ -14,8 +14,13 @@ module Application
) where
import Control.Monad.Logger (liftLoc, runLoggingT)
-import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr,
- pgPoolSize, runSqlPool)
+--import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr,
+-- pgPoolSize, runSqlPool)
+
+-- to use sqlite:
+import Database.Persist.Sqlite (createSqlitePool, runSqlPool,
+ sqlDatabase, sqlPoolSize)
+
import Import
import Language.Haskell.TH.Syntax (qLocation)
import Network.Wai (Middleware)
@@ -75,9 +80,14 @@ makeFoundation appSettings = do
logFunc = messageLoggerSource tempFoundation appLogger
-- Create the database connection pool
- pool <- flip runLoggingT logFunc $ createPostgresqlPool
- (pgConnStr $ appDatabaseConf appSettings)
- (pgPoolSize $ appDatabaseConf appSettings)
+ --pool <- flip runLoggingT logFunc $ createPostgresqlPool
+ -- (pgConnStr $ appDatabaseConf appSettings)
+ -- (pgPoolSize $ appDatabaseConf appSettings)
+ -- ^^ to use sqlite:
+ pool <- flip runLoggingT logFunc $ createSqlitePool
+ (sqlDatabase $ appDatabaseConf appSettings)
+ (sqlPoolSize $ appDatabaseConf appSettings)
+
-- Perform database migration using our application's logging settings.
runLoggingT (runSqlPool (runMigration migrateAll) pool) logFunc
diff --git a/Carnap-Server/Carnap-Server.cabal b/Carnap-Server/Carnap-Server.cabal
index 94d2e07..9123112 100644
--- a/Carnap-Server/Carnap-Server.cabal
+++ b/Carnap-Server/Carnap-Server.cabal
@@ -5,13 +5,15 @@ build-type: Simple
Flag dev
Description: Turn on development settings, like auto-reload templates.
- Default: False
+ Default: True
Flag library-only
Description: Build for use with "yesod devel"
- Default: False
+ Default: True
library
+ -- standard yesod template for lts-5.13
+ -- does *not* include fay-shared
hs-source-dirs: ., fay-shared, app
exposed-modules: Application
Foundation
@@ -73,7 +75,8 @@ library
, bytestring >= 0.9 && < 0.11
, text >= 0.11 && < 2.0
, persistent >= 2.0 && < 2.6
- , persistent-postgresql >= 2.1.1 && < 2.6
+-- , persistent-postgresql
+ , persistent-sqlite
, persistent-template >= 2.0 && < 2.6
, template-haskell
, shakespeare >= 2.0 && < 2.1
@@ -154,7 +157,8 @@ test-suite test
, yesod-core
, yesod
, persistent
- , persistent-postgresql
+-- , persistent-postgresql
+ , persistent-sqlite
, resourcet
, monad-logger
, shakespeare
diff --git a/Carnap-Server/Foundation.hs b/Carnap-Server/Foundation.hs
index 2ab0653..c83ce63 100644
--- a/Carnap-Server/Foundation.hs
+++ b/Carnap-Server/Foundation.hs
@@ -17,6 +17,8 @@ import qualified Data.Text.Encoding as TE
-- keep settings and values requiring initialization before your application
-- starts running, such as database connections. Every handler will have
-- access to the data present here.
+--
+-- Carnap: adds "appFayCommandHandler" to App
data App = App
{ appSettings :: AppSettings
, appStatic :: Static -- ^ Settings for static file serving.
diff --git a/Carnap-Server/Settings.hs b/Carnap-Server/Settings.hs
index 6ed4579..be9f3bb 100644
--- a/Carnap-Server/Settings.hs
+++ b/Carnap-Server/Settings.hs
@@ -6,13 +6,15 @@
-- declared in the Foundation.hs file.
module Settings where
-import ClassyPrelude.Yesod
+import ClassyPrelude.Yesod hiding (throw)
import Control.Exception (throw)
import Data.Aeson (Result (..), fromJSON, withObject, (.!=),
(.:?))
import Data.FileEmbed (embedFile)
import Data.Yaml (decodeEither')
-import Database.Persist.Postgresql (PostgresConf)
+--import Database.Persist.Postgresql (PostgresConf)
+-- ^^ to use sqlite:
+import Database.Persist.Sqlite (SqliteConf)
import Language.Haskell.TH.Syntax (Exp, Name, Q)
import Network.Wai.Handler.Warp (HostPreference)
import Yesod.Default.Config2 (applyEnvValue, configSettingsYml)
@@ -26,8 +28,10 @@ import Yesod.Fay
data AppSettings = AppSettings
{ appStaticDir :: String
-- ^ Directory from which to serve static files.
- , appDatabaseConf :: PostgresConf
+ --, appDatabaseConf :: PostgresConf
-- ^ Configuration settings for accessing the database.
+ -- ^^TO use sqlite: use
+ , appDatabaseConf :: SqliteConf
, appRoot :: Maybe Text
-- ^ Base for all generated URLs. If @Nothing@, determined
-- from the request headers.
diff --git a/Carnap-Server/config/keter.yml b/Carnap-Server/config/keter.yml
index 046442e..933ba81 100644
--- a/Carnap-Server/config/keter.yml
+++ b/Carnap-Server/config/keter.yml
@@ -21,6 +21,8 @@ stanzas:
# You can specify one or more hostnames for your application to respond
# to. The primary hostname will be used for generating your application
# root.
+ #- www.Carnap-Server.com
+ # ^^ TODO: change to any desired hostname
- 162.243.233.227
- Carnap.io
@@ -46,6 +48,7 @@ stanzas:
# - host: www.Carnap-Server.com
# # secure: false
# # port: 80
+ ## ^^ TODO: change to any desired hostname
# Uncomment to switch to a non-permanent redirect.
# status: 303
@@ -63,5 +66,5 @@ copy-to: [email protected]:/opt/keter/incoming/
# If you would like to have Keter automatically create a PostgreSQL database
# and set appropriate environment variables for it to be discovered, uncomment
# the following line.
-plugins:
- postgres: true
+# plugins:
+# postgres: true
diff --git a/Carnap-Server/config/settings.yml b/Carnap-Server/config/settings.yml
index 352bcc2..af415dd 100644
--- a/Carnap-Server/config/settings.yml
+++ b/Carnap-Server/config/settings.yml
@@ -23,14 +23,19 @@ ip-from-header: "_env:IP_FROM_HEADER:false"
# NB: If you need a numeric value (e.g. 123) to parse as a String, wrap it in single quotes (e.g. "_env:PGPASS:'123'")
# See https://github.com/yesodweb/yesod/wiki/Configuration#parsing-numeric-values-as-strings
-database:
- user: "_env:PGUSER:carnap"
- password: "_env:PGPASS:Carnap-Server"
- host: "_env:PGHOST:localhost"
- port: "_env:PGPORT:5432"
- # See config/test-settings.yml for an override during tests
- database: "_env:PGDATABASE:carnapdb"
- poolsize: "_env:PGPOOLSIZE:10"
+# to use SQLite, change database stanza to:
+database:
+ database: "_env:SQLITE_DATABASE:Carnap-Server.sqlite3"
+ poolsize: "_env:SQLITE_POOLSIZE:10"
+
+#database:
+# user: "_env:PGUSER:carnap"
+# password: "_env:PGPASS:Carnap-Server"
+# host: "_env:PGHOST:localhost"
+# port: "_env:PGPORT:5432"
+# # See config/test-settings.yml for an override during tests
+# database: "_env:PGDATABASE:carnapdb"
+# poolsize: "_env:PGPOOLSIZE:10"
copyright: Copyright 2015-2016 G. Leach-Krouse and J. Ehrlich
#analytics: UA-YOURCODE
diff --git a/Carnap-Server/config/test-settings.yml b/Carnap-Server/config/test-settings.yml
index 1050597..7c4821e 100644
--- a/Carnap-Server/config/test-settings.yml
+++ b/Carnap-Server/config/test-settings.yml
@@ -5,5 +5,7 @@ database:
# would like to have environment variable overrides, you could instead use
# something like:
#
- database: "_env:PGDATABASE:carnapdb"
- # database: Carnap-Server_LOWER_test
+ # database: "_env:PGDATABASE:Carnap-Server_LOWER_test"
+ # or for SQLITE:
+ database: "_env:SQLITE_DATABASE:Carnap-Server_test.sqlite3"
+ #database: Carnap-Server_LOWER_test
diff --git a/Carnap-Server/test/TestImport.hs b/Carnap-Server/test/TestImport.hs
index a460071..2f03a97 100644
--- a/Carnap-Server/test/TestImport.hs
+++ b/Carnap-Server/test/TestImport.hs
@@ -14,14 +14,17 @@ import Text.Shakespeare.Text (st)
import Yesod.Default.Config2 (ignoreEnv, loadYamlSettings)
import Yesod.Test as X
+-- Wiping the database
+import Database.Persist.Sqlite (sqlDatabase, wrapConnection, createSqlPool)
+import qualified Database.Sqlite as Sqlite
+import Control.Monad.Logger (runLoggingT)
+import Settings (appDatabaseConf)
+import Yesod.Core (messageLoggerSource)
+
runDB :: SqlPersistM a -> YesodExample App a
runDB query = do
- app <- getTestYesod
- liftIO $ runDBWithApp app query
-
-runDBWithApp :: App -> SqlPersistM a -> IO a
-runDBWithApp app query = runSqlPersistMPool query (appConnPool app)
-
+ pool <- fmap appConnPool getTestYesod
+ liftIO $ runSqlPersistMPool query pool
withApp :: SpecWith (TestApp App) -> Spec
withApp = before $ do
@@ -38,20 +41,35 @@ withApp = before $ do
-- 'withApp' calls it before each test, creating a clean environment for each
-- spec to run in.
wipeDB :: App -> IO ()
-wipeDB app = runDBWithApp app $ do
- tables <- getTables
- sqlBackend <- ask
+wipeDB app = do
+ -- In order to wipe the database, we need to temporarily disable foreign key checks.
+ -- Unfortunately, disabling FK checks in a transaction is a noop in SQLite.
+ -- Normal Persistent functions will wrap your SQL in a transaction,
+ -- so we create a raw SQLite connection to disable foreign keys.
+ -- Foreign key checks are per-connection, so this won't effect queries outside this function.
+
+ -- Aside: SQLite by default *does not enable foreign key checks*
+ -- (disabling foreign keys is only necessary for those who specifically enable them).
+ let settings = appSettings app
+ sqliteConn <- rawConnection (sqlDatabase $ appDatabaseConf settings)
+ disableForeignKeys sqliteConn
- let escapedTables = map (connEscapeName sqlBackend . DBName) tables
- query = "TRUNCATE TABLE " ++ intercalate ", " escapedTables
- rawExecute query []
+ let logFunc = messageLoggerSource app (appLogger app)
+ pool <- runLoggingT (createSqlPool (wrapConnection sqliteConn) 1) logFunc
+
+ flip runSqlPersistMPool pool $ do
+ tables <- getTables
+ sqlBackend <- ask
+ let queries = map (\t -> "DELETE FROM " ++ (connEscapeName sqlBackend $ DBName t)) tables
+ forM_ queries (\q -> rawExecute q [])
+
+rawConnection :: Text -> IO Sqlite.Connection
+rawConnection t = Sqlite.open t
+
+disableForeignKeys :: Sqlite.Connection -> IO ()
+disableForeignKeys conn = Sqlite.prepare conn "PRAGMA foreign_keys = OFF;" >>= void . Sqlite.step
getTables :: MonadIO m => ReaderT SqlBackend m [Text]
getTables = do
- tables <- rawSql [st|
- SELECT table_name
- FROM information_schema.tables
- WHERE table_schema = 'public';
- |] []
-
- return $ map unSingle tables
+ tables <- rawSql "SELECT name FROM sqlite_master WHERE type = 'table';" []
+ return (fmap unSingle tables)
\ No newline at end of file
diff --git a/semigroupoids-5.0.1/.ghci b/semigroupoids-5.0.1/.ghci
new file mode 100644
index 0000000..231eb17
--- /dev/null
+++ b/semigroupoids-5.0.1/.ghci
@@ -0,0 +1 @@
+:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
diff --git a/semigroupoids-5.0.1/.travis.yml b/semigroupoids-5.0.1/.travis.yml
new file mode 100644
index 0000000..44bbca7
--- /dev/null
+++ b/semigroupoids-5.0.1/.travis.yml
@@ -0,0 +1,50 @@
+language: c
+sudo: false
+
+matrix:
+ include:
+ - env: CABALVER=1.16 GHCVER=7.4.2
+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}}
+ - env: CABALVER=1.16 GHCVER=7.6.3
+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
+ - env: CABALVER=1.18 GHCVER=7.8.4
+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
+ - env: CABALVER=1.22 GHCVER=7.10.1
+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1],sources: [hvr-ghc]}}
+ - env: CABALVER=head GHCVER=head
+ addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
+
+ allow_failures:
+ - env: CABALVER=head GHCVER=head
+
+before_install:
+ - export PATH=~/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
+ - export CABAL=cabal-$CABALVER
+ - travis_retry $CABAL update
+ - if [ "$CABALVER" = "1.22" ]; then $CABAL install Cabal-1.22.4.0; fi
+ - $CABAL --version
+
+install:
+ - $CABAL install --enable-tests --only-dependencies
+
+script:
+ - $CABAL configure -v2 --enable-tests
+ - $CABAL build
+ - $CABAL test
+ - $CABAL sdist
+ - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;
+ cd dist/;
+ if [ -f "$SRC_TGZ" ]; then
+ $CABAL install "$SRC_TGZ";
+ else
+ echo "expected '$SRC_TGZ' not found";
+ exit 1;
+ fi
+
+notifications:
+ irc:
+ channels:
+ - "irc.freenode.org#haskell-lens"
+ skip_join: true
+ template:
+ - "\x0313semigroupoids\x0f/\x0306%{branch}\x0f \x0314%{commit}\x0f %{message} \x0302\x1f%{build_url}\x0f"
diff --git a/semigroupoids-5.0.1/.vim.custom b/semigroupoids-5.0.1/.vim.custom
new file mode 100644
index 0000000..86321a8
--- /dev/null
+++ b/semigroupoids-5.0.1/.vim.custom
@@ -0,0 +1,31 @@
+" Add the following to your .vimrc to automatically load this on startup
+
+" if filereadable(".vim.custom")
+" so .vim.custom
+" endif
+
+function StripTrailingWhitespace()
+ let myline=line(".")
+ let mycolumn = col(".")
+ silent %s/ *$//
+ call cursor(myline, mycolumn)
+endfunction
+
+" enable syntax highlighting
+syntax on
+
+" search for the tags file anywhere between here and /
+set tags=TAGS;/
+
+" highlight tabs and trailing spaces
+set listchars=tab:‗‗,trail:‗
+set list
+
+" f2 runs hasktags
+map <F2> :exec ":!hasktags -x -c --ignore src"<CR><CR>
+
+" strip trailing whitespace before saving
+" au BufWritePre *.hs,*.markdown silent! cal StripTrailingWhitespace()
+
+" rebuild hasktags after saving
+au BufWritePost *.hs silent! :exec ":!hasktags -x -c --ignore src"
diff --git a/semigroupoids-5.0.1/CHANGELOG.markdown b/semigroupoids-5.0.1/CHANGELOG.markdown
new file mode 100644
index 0000000..6c3197c
--- /dev/null
+++ b/semigroupoids-5.0.1/CHANGELOG.markdown
@@ -0,0 +1,86 @@
+5.0.1
+-------
+* `transformers-compat` 0.5 support
+* Removed some redundant constraints.
+* GHC 8 support
+
+5.0.0.4
+-------
+* `doctest` 0.10 support
+
+5.0.0.2
+-------
+* Bugfix for GHC 7.4. PolyKinds on 7.4 cause all sorts of haskell interface file errors. One of the #if guards that turned it off on 7.4 was missing and has been fixed.
+
+5.0.0.1
+-------
+* Added the CHANGELOG to the distribution so that `hackage` can link to it in the haddocks.
+
+5
+-
+* Absorbed `Data.Bifunctor.Apply`, `Data.Semigroup.Bifoldable` and `Data.Semigroup.Traversable` from `bifunctors`.
+* This caused us to pick up a dependency on `tagged`.
+* Exiled `Data.Semifunctor.*`, `Data.Semigroupoid.Product` and `Data.Semigroupoid.Coproduct` to `semigroupoid-extras`.
+* This let us open up to older versions of GHC again.
+* Set an explicit fixity for `-<-` and `->-`.
+
+4.5
+---
+* Major changes to the API to support PolyKinds and DataKinds. This necessarily shuts off GHC <= 7.4.
+* Orphan instances have moved upstream into a common `base-orphans` package.
+
+4.3.1
+-----
+* Added `asum1` to `Data.Semigroup.Foldable`.
+
+4.3.0.1
+-------
+* Support for 'ConstrainedClassMethods' is currently required for GHC HEAD.
+
+4.3
+-----
+* Added missing instances for `ExceptT`. Obtain it via `transformers-compat` if need be for old `transformers` versions.
+* Several `Bind` and `Apply` instances now require somewhat more minimal contexts.
+
+4.2
+---
+* Backported `Foldable`/`Traversable` instances from `lens`
+
+4.1
+---
+* `Foldable1`/`Traversable1` for tuples
+
+4.0.4
+-----
+* `contravariant` 1.0 support.
+
+4.0.3
+---
+* Added flags to provide unsupported cabal sandbox build modes.
+
+4.0.1
+-----
+* Fixed bitrot in the `Data.Functor.Extend` documentation.
+* Fixed warnings on GHC 7.8.1rc2 caused by importing `Control.Monad.Instances`.
+
+4.0
+---
+* Merged in the contents of the `groupoids` and `semigroupoid-extras` packages.
+
+3.1
+---
+* Added the [rectangular band](http://en.wikipedia.org/wiki/Band_(mathematics)#Rectangular_bands) `Semigroupoid` for `(,)`. Would that make it a Bandoid?
+
+3.0.3
+-----
+* Claim to be `Trustworthy` where necessary
+
+3.0.2
+-----
+* Tightened the upper bounds slightly to enable PVP compliance while retaining a flexible development cycle.
+* Raised the upper bound on `contravariant`.
+
+3.0.1
+-----
+* Removed upper bounds relative to my other packages
+* Refactored directory layout
diff --git a/semigroupoids-5.0.1/LICENSE b/semigroupoids-5.0.1/LICENSE
new file mode 100644
index 0000000..cdfe4f0
--- /dev/null
+++ b/semigroupoids-5.0.1/LICENSE
@@ -0,0 +1,26 @@
+Copyright 2011-2015 Edward Kmett
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/semigroupoids-5.0.1/README.markdown b/semigroupoids-5.0.1/README.markdown
new file mode 100644
index 0000000..725075e
--- /dev/null
+++ b/semigroupoids-5.0.1/README.markdown
@@ -0,0 +1,15 @@
+semigroupoids
+==========
+
+[![Hackage](https://img.shields.io/hackage/v/semigroupoids.svg)](https://hackage.haskell.org/package/semigroupoids) [![Build Status](https://secure.travis-ci.org/ekmett/semigroupoids.png?branch=master)](http://travis-ci.org/ekmett/semigroupoids)
+
+A semigroupoid is a `Category` without `id`.
+
+Contact Information
+-------------------
+
+Contributions and bug reports are welcome!
+
+Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.
+
+-Edward Kmett
diff --git a/semigroupoids-5.0.1/Setup.lhs b/semigroupoids-5.0.1/Setup.lhs
new file mode 100644
index 0000000..d331fe4
--- /dev/null
+++ b/semigroupoids-5.0.1/Setup.lhs
@@ -0,0 +1,46 @@
+#!/usr/bin/runhaskell
+\begin{code}
+{-# OPTIONS_GHC -Wall #-}
+module Main (main) where
+
+import Data.List ( nub )
+import Data.Version ( showVersion )
+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )
+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
+import Distribution.Simple.BuildPaths ( autogenModulesDir )
+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag)
+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
+import Distribution.Verbosity ( Verbosity )
+import System.FilePath ( (</>) )
+
+main :: IO ()
+main = defaultMainWithHooks simpleUserHooks
+ { buildHook = \pkg lbi hooks flags -> do
+ generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
+ buildHook simpleUserHooks pkg lbi hooks flags
+ , postHaddock = \args flags pkg lbi -> do
+ postHaddock simpleUserHooks args flags pkg lbi
+ }
+
+generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
+generateBuildModule verbosity pkg lbi = do
+ let dir = autogenModulesDir lbi
+ createDirectoryIfMissingVerbose verbosity True dir
+ withLibLBI pkg lbi $ \_ libcfg -> do
+ withTestLBI pkg lbi $ \suite suitecfg -> do
+ rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
+ [ "module Build_" ++ testName suite ++ " where"
+ , "deps :: [String]"
+ , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
+ ]
+ where
+ formatdeps = map (formatone . snd)
+ formatone p = case packageName p of
+ PackageName n -> n ++ "-" ++ showVersion (packageVersion p)
+
+testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
+
+\end{code}
diff --git a/semigroupoids-5.0.1/semigroupoids.cabal b/semigroupoids-5.0.1/semigroupoids.cabal
new file mode 100644
index 0000000..ff0a095
--- /dev/null
+++ b/semigroupoids-5.0.1/semigroupoids.cabal
@@ -0,0 +1,181 @@
+name: semigroupoids
+category: Control, Comonads
+version: 5.0.1
+x-revision: 2
+license: BSD3
+cabal-version: >= 1.8
+license-file: LICENSE
+author: Edward A. Kmett
+maintainer: Edward A. Kmett <[email protected]>
+stability: provisional
+homepage: http://github.com/ekmett/semigroupoids
+bug-reports: http://github.com/ekmett/semigroupoids/issues
+copyright: Copyright (C) 2011-2015 Edward A. Kmett
+build-type: Custom
+tested-with: GHC==7.0.1, GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1
+synopsis: Semigroupoids: Category sans id
+extra-source-files:
+ .ghci
+ .travis.yml
+ .vim.custom
+ README.markdown
+ CHANGELOG.markdown
+description:
+ Provides a wide array of (semi)groupoids and operations for working with them.
+ .
+ A 'Semigroupoid' is a 'Category' without the requirement of identity arrows for every object in the category.
+ .
+ A 'Category' is any 'Semigroupoid' for which the Yoneda lemma holds.
+ .
+ When working with comonads you often have the @\<*\>@ portion of an @Applicative@, but
+ not the @pure@. This was captured in Uustalu and Vene's \"Essence of Dataflow Programming\"
+ in the form of the @ComonadZip@ class in the days before @Applicative@. Apply provides a weaker invariant, but for the comonads used for data flow programming (found in the streams package), this invariant is preserved. Applicative function composition forms a semigroupoid.
+ .
+ Similarly many structures are nearly a comonad, but not quite, for instance lists provide a reasonable 'extend' operation in the form of 'tails', but do not always contain a value.
+ .
+ Ideally the following relationships would hold:
+ .
+ > Foldable ----> Traversable <--- Functor ------> Alt ---------> Plus Semigroupoid
+ > | | | | |
+ > v v v v v
+ > Foldable1 ---> Traversable1 Apply --------> Applicative -> Alternative Category
+ > | | | |
+ > v v v v
+ > Bind ---------> Monad -------> MonadPlus Arrow
+ >
+ .
+ Apply, Bind, and Extend (not shown) give rise the Static, Kleisli and Cokleisli semigroupoids respectively.
+ .
+ This lets us remove many of the restrictions from various monad transformers
+ as in many cases the binding operation or @\<*\>@ operation does not require them.
+ .
+ Finally, to work with these weaker structures it is beneficial to have containers
+ that can provide stronger guarantees about their contents, so versions of 'Traversable'
+ and 'Foldable' that can be folded with just a 'Semigroup' are added.
+
+source-repository head
+ type: git
+ location: git://github.com/ekmett/semigroupoids.git
+
+flag containers
+ description:
+ You can disable the use of the `containers` package using `-f-containers`.
+ .
+ Disabing this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
+ default: True
+ manual: True
+
+flag contravariant
+ description:
+ You can disable the use of the `contravariant` package using `-f-contravariant`.
+ .
+ Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
+ .
+ If disabled we will not supply instances of `Contravariant`
+ .
+ default: True
+ manual: True
+
+flag distributive
+ description:
+ You can disable the use of the `distributive` package using `-f-distributive`.
+ .
+ Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
+ .
+ If disabled we will not supply instances of `Distributive`
+ .
+ default: True
+ manual: True
+
+flag doctests
+ description:
+ You can disable testing with doctests using `-f-doctests`.
+ default: True
+ manual: True
+
+flag comonad
+ description:
+ You can disable the use of the `comonad` package using `-f-comonad`.
+ .
+ Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
+ .
+ If disabled we will not supply instances of `Comonad`
+ .
+ default: True
+ manual: True
+
+flag tagged
+ description:
+ You can disable the use of the `tagged` package using `-f-tagged`.
+ .
+ Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
+ default: True
+ manual: True
+
+library
+ build-depends:
+ base
+ , base-orphans
+ , bifunctors
+ , semigroups
+ , transformers
+ , transformers-compat
+ , tagged
+
+ if flag(containers)
+ build-depends: containers >= 0.3 && < 0.6
+
+ if flag(contravariant)
+ build-depends: contravariant >= 0.2.0.1 && < 2
+
+ if flag(distributive)
+ build-depends: distributive >= 0.2.2 && < 1
+
+ if flag(comonad)
+ build-depends: comonad >= 4.2.6 && < 6
+
+-- if flag(tagged)
+-- build-depends: tagged >= 0.8.5 && < 1
+
+ hs-source-dirs: src
+
+ exposed-modules:
+ Data.Bifunctor.Apply
+ Data.Functor.Alt
+ Data.Functor.Apply
+ Data.Functor.Bind
+ Data.Functor.Bind.Class
+ Data.Functor.Bind.Trans
+ Data.Functor.Extend
+ Data.Functor.Plus
+ Data.Groupoid
+ Data.Isomorphism
+ Data.Semigroup.Bifoldable
+ Data.Semigroup.Bitraversable
+ Data.Semigroup.Foldable
+ Data.Semigroup.Foldable.Class
+ Data.Semigroup.Traversable
+ Data.Semigroup.Traversable.Class
+ Data.Semigroupoid
+ Data.Semigroupoid.Dual
+ Data.Semigroupoid.Ob
+ Data.Semigroupoid.Static
+ Data.Traversable.Instances
+
+ ghc-options: -Wall -fno-warn-warnings-deprecations
+
+test-suite doctests
+ type: exitcode-stdio-1.0
+ main-is: doctests.hs
+ hs-source-dirs: test
+ ghc-options: -Wall -fno-warn-warnings-deprecations
+
+ if !flag(doctests)
+ buildable: False
+ else
+ build-depends:
+ base >= 4 && < 5,
+ doctest >= 0.9.1 && < 0.11,
+ directory >= 1.0,
+ filepath
+
diff --git a/semigroupoids-5.0.1/src/Data/Bifunctor/Apply.hs b/semigroupoids-5.0.1/src/Data/Bifunctor/Apply.hs
new file mode 100644
index 0000000..3a865f2
--- /dev/null
+++ b/semigroupoids-5.0.1/src/Data/Bifunctor/Apply.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE CPP #-}
+-----------------------------------------------------------------------------
+-- |
+-- Copyright : (C) 2011-2015 Edward Kmett
+-- License : BSD-style (see the file LICENSE)
+--
+-- Maintainer : Edward Kmett <[email protected]>
+-- Stability : provisional
+-- Portability : portable
+--
+----------------------------------------------------------------------------
+module Data.Bifunctor.Apply (
+ -- * Biappliable bifunctors
+ Bifunctor(..)
+ , Biapply(..)
+ , (<<$>>)
+ , (<<..>>)
+ , bilift2
+ , bilift3
+ ) where
+
+import Data.Functor.Bind.Class
+import Data.Biapplicative
+
+infixl 4 <<..>>
+
+(<<..>>) :: Biapply p => p a c -> p (a -> b) (c -> d) -> p b d
+(<<..>>) = bilift2 (flip id) (flip id)
+{-# INLINE (<<..>>) #-}
+
+-- | Lift binary functions
+bilift2 :: Biapply w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f
+bilift2 f g a b = bimap f g <<$>> a <<.>> b
+{-# INLINE bilift2 #-}
+
+-- | Lift ternary functions
+bilift3 :: Biapply w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h
+bilift3 f g a b c = bimap f g <<$>> a <<.>> b <<.>> c
+{-# INLINE bilift3 #-}
diff --git a/semigroupoids-5.0.1/src/Data/Functor/Alt.hs b/semigroupoids-5.0.1/src/Data/Functor/Alt.hs
new file mode 100644
index 0000000..7c326df
--- /dev/null
+++ b/semigroupoids-5.0.1/src/Data/Functor/Alt.hs
@@ -0,0 +1,213 @@
+{-# LANGUAGE CPP #-}
+
+#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL <= 706 && defined(MIN_VERSION_comonad) && !(MIN_VERSION_comonad(3,0,3))
+{-# LANGUAGE Trustworthy #-}
+#endif
+
+#if __GLASGOW_HASKELL__ >= 711
+{-# LANGUAGE ConstrainedClassMethods #-}
+#endif
+-----------------------------------------------------------------------------
+-- |
+-- Module : Data.Functor.Alt
+-- Copyright : (C) 2011-2015 Edward Kmett
+-- License : BSD-style (see the file LICENSE)
+--
+-- Maintainer : Edward Kmett <[email protected]>
+-- Stability : provisional
+-- Portability : portable
+--
+----------------------------------------------------------------------------
+module Data.Functor.Alt
+ ( Alt(..)
+ , module Data.Functor.Apply
+ ) where
+
+import Control.Applicative hiding (some, many)
+import Control.Applicative.Backwards
+import Control.Applicative.Lift
+import Control.Arrow
+import Control.Exception (catch, SomeException)
+import Control.Monad
+import Control.Monad.Trans.Identity
+import Control.Monad.Trans.Error
+import Control.Monad.Trans.Except
+import Control.Monad.Trans.List
+import Control.Monad.Trans.Maybe
+import Control.Monad.Trans.Reader
+import qualified Control.Monad.Trans.RWS.Strict as Strict
+import qualified Control.Monad.Trans.State.Strict as Strict
+import qualified Control.Monad.Trans.Writer.Strict as Strict
+import qualified Control.Monad.Trans.RWS.Lazy as Lazy
+import qualified Control.Monad.Trans.State.Lazy as Lazy
+import qualified Control.Monad.Trans.Writer.Lazy as Lazy
+import Data.Functor.Apply
+import Data.Functor.Bind
+import Data.Functor.Compose
+import Data.Functor.Product
+import Data.Functor.Reverse
+import Data.Semigroup hiding (Product)
+import Data.List.NonEmpty (NonEmpty(..))
+import Prelude (($),Either(..),Maybe(..),const,IO,Ord,(++),(.),either)
+
+#ifdef MIN_VERSION_containers
+import qualified Data.IntMap as IntMap
+import Data.IntMap (IntMap)
+import Data.Sequence (Seq)
+import qualified Data.Map as Map
+import Data.Map (Map)
+#endif
+
+infixl 3 <!>
+
+-- | Laws:
+--
+-- > <!> is associative: (a <!> b) <!> c = a <!> (b <!> c)
+-- > <$> left-distributes over <!>: f <$> (a <!> b) = (f <$> a) <!> (f <$> b)
+--
+-- If extended to an 'Alternative' then '<!>' should equal '<|>'.
+--
+-- Ideally, an instance of 'Alt' also satisfies the \"left distributon\" law of
+-- MonadPlus with respect to '<.>':
+--
+-- > <.> right-distributes over <!>: (a <!> b) <.> c = (a <.> c) <!> (b <.> c)
+--
+-- But 'Maybe', 'IO', @'Either' a@, @'ErrorT' e m@, and 'STM' satisfy the alternative
+-- \"left catch\" law instead:
+--
+-- > pure a <!> b = pure a
+--
+-- However, this variation cannot be stated purely in terms of the dependencies of 'Alt'.
+--
+-- When and if MonadPlus is successfully refactored, this class should also
+-- be refactored to remove these instances.
+--
+-- The right distributive law should extend in the cases where the a 'Bind' or 'Monad' is
+-- provided to yield variations of the right distributive law:
+--
+-- > (m <!> n) >>- f = (m >>- f) <!> (m >>- f)
+-- > (m <!> n) >>= f = (m >>= f) <!> (m >>= f)
+
+class Functor f => Alt f where
+ -- | '<|>' without a required @empty@
+ (<!>) :: f a -> f a -> f a
+
+ some :: Applicative f => f a -> f [a]
+ some v = some_v
+ where many_v = some_v <!> pure []
+ some_v = (:) <$> v <*> many_v
+
+ many :: Applicative f => f a -> f [a]
+ many v = many_v
+ where many_v = some_v <!> pure []
+ some_v = (:) <$> v <*> many_v
+
+
+instance Alt (Either a) where
+ Left _ <!> b = b
+ a <!> _ = a
+
+-- | This instance does not actually satisfy the ('<.>') right distributive law
+-- It instead satisfies the "Left-Catch" law
+instance Alt IO where
+ m <!> n = catch m (go n) where
+ go :: x -> SomeException -> x
+ go = const
+
+instance Alt [] where
+ (<!>) = (++)
+
+instance Alt Maybe where
+ Nothing <!> b = b
+ a <!> _ = a
+
+instance Alt Option where
+ (<!>) = (<|>)
+
+instance MonadPlus m => Alt (WrappedMonad m) where
+ (<!>) = (<|>)
+
+instance ArrowPlus a => Alt (WrappedArrow a b) where
+ (<!>) = (<|>)
+
+#ifdef MIN_VERSION_containers
+instance Ord k => Alt (Map k) where
+ (<!>) = Map.union
+
+instance Alt IntMap where
+ (<!>) = IntMap.union
+
+instance Alt Seq where
+ (<!>) = mappend
+#endif
+
+instance Alt NonEmpty where
+ (a :| as) <!> ~(b :| bs) = a :| (as ++ b : bs)
+
+instance Alternative f => Alt (WrappedApplicative f) where
+ WrapApplicative a <!> WrapApplicative b = WrapApplicative (a <|> b)
+
+instance Alt f => Alt (IdentityT f) where
+ IdentityT a <!> IdentityT b = IdentityT (a <!> b)
+
+instance Alt f => Alt (ReaderT e f) where
+ ReaderT a <!> ReaderT b = ReaderT $ \e -> a e <!> b e
+
+instance (Bind f, Monad f) => Alt (MaybeT f) where
+ MaybeT a <!> MaybeT b = MaybeT $ do
+ v <- a
+ case v of
+ Nothing -> b
+ Just _ -> return v
+
+instance (Bind f, Monad f) => Alt (ErrorT e f) where
+ ErrorT m <!> ErrorT n = ErrorT $ do
+ a <- m
+ case a of
+ Left _ -> n
+ Right r -> return (Right r)
+
+instance (Bind f, Monad f, Semigroup e) => Alt (ExceptT e f) where
+ ExceptT m <!> ExceptT n = ExceptT $ do
+ a <- m
+ case a of
+ Left e -> liftM (either (Left . (<>) e) Right) n
+ Right x -> return (Right x)
+
+instance Apply f => Alt (ListT f) where
+ ListT a <!> ListT b = ListT $ (<!>) <$> a <.> b
+
+instance Alt f => Alt (Strict.StateT e f) where
+ Strict.StateT m <!> Strict.StateT n = Strict.StateT $ \s -> m s <!> n s
+
+instance Alt f => Alt (Lazy.StateT e f) where
+ Lazy.StateT m <!> Lazy.StateT n = Lazy.StateT $ \s -> m s <!> n s
+