-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Promote and single Foldable, Traversable, Const, and Identity (#337)
* Promote and single Foldable, Traversable, Const, and Identity This completes the `Data.Singletons.Prelude.*` changes necessary to support `Monad` and friends. This: * Adds the appropriate modules for the `Foldable` and `Traversable` classes, as well as the `Identity` and `Const` newtypes. * Uncomments various things in `Data.Singletons.Prelude.{Applicative,Monad}` that couldn't be supported before due to the lack of the classes in the previous bullet points. * Reexports the appropriate `Foldable`/`Traversable` functions from `Data.{Promotion,Singletons}.Prelude.List` to mirror what `Data.List` does. This required some reorganization of internal modules, but was otherwise straightforward. Checks off the second bullet point in #184. * Use list comprehensions in a couple more places
- Loading branch information
1 parent
bd71aed
commit 56e4676
Showing
28 changed files
with
2,255 additions
and
646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Promotion.Prelude.Const | ||
-- Copyright : (C) 2018 Ryan Scott | ||
-- License : BSD-style (see LICENSE) | ||
-- Maintainer : Richard Eisenberg ([email protected]) | ||
-- Stability : experimental | ||
-- Portability : non-portable | ||
-- | ||
-- Exports defunctionalization symbosl for the 'Const' data type. | ||
-- | ||
----------------------------------------------------------------------------- | ||
|
||
module Data.Promotion.Prelude.Const ( | ||
-- * Defunctionalization symbols | ||
ConstSym0, ConstSym1, | ||
GetConstSym0, GetConstSym1 | ||
) where | ||
|
||
import Data.Singletons.Prelude.Const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Promotion.Prelude.Foldable | ||
-- Copyright : (C) 2018 Ryan Scott | ||
-- License : BSD-style (see LICENSE) | ||
-- Maintainer : Ryan Scott | ||
-- Stability : experimental | ||
-- Portability : non-portable | ||
-- | ||
-- Defines the promoted version of the 'Foldable' type class. | ||
-- | ||
---------------------------------------------------------------------------- | ||
|
||
module Data.Promotion.Prelude.Foldable ( | ||
PFoldable(..), | ||
|
||
FoldrM, FoldlM, | ||
Traverse_, For_, SequenceA_, Asum, | ||
MapM_, ForM_, Sequence_, Msum, | ||
Concat, ConcatMap, And, Or, Any, All, MaximumBy, MinimumBy, | ||
NotElem, Find, | ||
|
||
-- * Defunctionalization symbols | ||
FoldSym0, FoldSym1, | ||
FoldMapSym0, FoldMapSym1, FoldMapSym2, | ||
FoldrSym0, FoldrSym1, FoldrSym2, FoldrSym3, | ||
Foldr'Sym0, Foldr'Sym1, Foldr'Sym2, Foldr'Sym3, | ||
FoldlSym0, FoldlSym1, FoldlSym2, FoldlSym3, | ||
Foldl'Sym0, Foldl'Sym1, Foldl'Sym2, Foldl'Sym3, | ||
Foldr1Sym0, Foldr1Sym1, Foldr1Sym2, | ||
Foldl1Sym0, Foldl1Sym1, Foldl1Sym2, | ||
ToListSym0, ToListSym1, | ||
NullSym0, NullSym1, | ||
LengthSym0, LengthSym1, | ||
ElemSym0, ElemSym1, ElemSym2, | ||
MaximumSym0, MaximumSym1, | ||
MinimumSym0, MinimumSym1, | ||
SumSym0, SumSym1, | ||
ProductSym0, ProductSym1, | ||
|
||
FoldrMSym0, FoldrMSym1, FoldrMSym2, FoldrMSym3, | ||
FoldlMSym0, FoldlMSym1, FoldlMSym2, FoldlMSym3, | ||
|
||
Traverse_Sym0, Traverse_Sym1, Traverse_Sym2, | ||
For_Sym0, For_Sym1, For_Sym2, | ||
SequenceA_Sym0, SequenceA_Sym1, | ||
AsumSym0, AsumSym1, | ||
|
||
MapM_Sym0, MapM_Sym1, MapM_Sym2, | ||
ForM_Sym0, ForM_Sym1, ForM_Sym2, | ||
Sequence_Sym0, Sequence_Sym1, | ||
MsumSym0, MsumSym1, | ||
|
||
ConcatSym0, ConcatSym1, | ||
ConcatMapSym0, ConcatMapSym1, ConcatMapSym2, | ||
AndSym0, AndSym1, | ||
OrSym0, OrSym1, | ||
AnySym0, AnySym1, AnySym2, | ||
AllSym0, AllSym1, AllSym2, | ||
MaximumBySym0, MaximumBySym1, MaximumBySym2, | ||
MinimumBySym0, MinimumBySym1, MinimumBySym2, | ||
|
||
NotElemSym0, NotElemSym1, NotElemSym2, | ||
FindSym0, FindSym1, FindSym2 | ||
) where | ||
|
||
import Data.Singletons.Prelude.Foldable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Promotion.Prelude.Identity | ||
-- Copyright : (C) 2018 Ryan Scott | ||
-- License : BSD-style (see LICENSE) | ||
-- Maintainer : Richard Eisenberg ([email protected]) | ||
-- Stability : experimental | ||
-- Portability : non-portable | ||
-- | ||
-- Exports the defunctionalization symbols for the 'Identity' data type. | ||
-- | ||
----------------------------------------------------------------------------- | ||
|
||
module Data.Promotion.Prelude.Identity ( | ||
-- * Defunctionalization symbols | ||
IdentitySym0, IdentitySym1, | ||
RunIdentitySym0, RunIdentitySym1 | ||
) where | ||
|
||
import Data.Singletons.Prelude.Identity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Promotion.Prelude.Traversable | ||
-- Copyright : (C) 2018 Ryan Scott | ||
-- License : BSD-style (see LICENSE) | ||
-- Maintainer : Ryan Scott | ||
-- Stability : experimental | ||
-- Portability : non-portable | ||
-- | ||
-- Defines the promoted version of the 'Traversable' type class. | ||
-- | ||
---------------------------------------------------------------------------- | ||
|
||
module Data.Promotion.Prelude.Traversable ( | ||
PTraversable(..), | ||
For, ForM, MapAccumL, MapAccumR, FmapDefault, FoldMapDefault, | ||
|
||
-- * Defunctionalization symbols | ||
TraverseSym0, TraverseSym1, TraverseSym2, | ||
SequenceASym0, SequenceASym1, | ||
MapMSym0, MapMSym1, MapMSym2, | ||
SequenceSym0, SequenceSym1, | ||
|
||
ForSym0, ForSym1, ForSym2, | ||
ForMSym0, ForMSym1, ForMSym2, | ||
MapAccumLSym0, MapAccumLSym1, MapAccumLSym2, MapAccumLSym3, | ||
MapAccumRSym0, MapAccumRSym1, MapAccumRSym2, MapAccumRSym3, | ||
FmapDefaultSym0, FmapDefaultSym1, FmapDefaultSym2, | ||
FoldMapDefaultSym0, FoldMapDefaultSym1, FoldMapDefaultSym2 | ||
) where | ||
|
||
import Data.Singletons.Prelude.Traversable |
Oops, something went wrong.