Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
head.hackage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
head.hackage
Commits
ff71f075
Commit
ff71f075
authored
2 years ago
by
Tobias Haslop
Browse files
Options
Downloads
Patches
Plain Diff
Add Folddable/Traversable instances in furthark
parent
7b399ca4
No related branches found
No related tags found
1 merge request
!296
Draft: Add quantified superclasses to Bifoldable and Bitraversable
Pipeline
#78837
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
patches/futhark-0.24.2.patch
+68
-0
68 additions, 0 deletions
patches/futhark-0.24.2.patch
with
68 additions
and
0 deletions
patches/futhark-0.24.2.patch
+
68
−
0
View file @
ff71f075
...
...
@@ -11,3 +11,71 @@ index cbdc3e1..9e13b5e 100644
import Data.Int (Int64)
import Data.List (foldl', transpose)
import Data.Map qualified as M
diff --git a/src/Futhark/IR/Syntax/Core.hs b/src/Futhark/IR/Syntax/Core.hs
index f61a679..f2023f4 100644
--- a/src/Futhark/IR/Syntax/Core.hs
+++ b/src/Futhark/IR/Syntax/Core.hs
@@ -248,7 +248,13 @@
instance Bitraversable TypeBase where
bitraverse _ _ (Mem s) = pure $ Mem s
instance Functor (TypeBase shape) where
- fmap = second
+ fmap = fmapDefault
+
+instance Foldable (TypeBase shape) where
+ foldMap = foldMapDefault
+
+instance Traversable (TypeBase shape) where
+ traverse = bitraverse pure
instance Bifunctor TypeBase where
bimap = bimapDefault
diff --git a/src/Language/Futhark/Syntax.hs b/src/Language/Futhark/Syntax.hs
index 527c5ad..06615b9 100644
--- a/src/Language/Futhark/Syntax.hs
+++ b/src/Language/Futhark/Syntax.hs
@@ -287,7 +287,13 @@
instance Bitraversable RetTypeBase where
bitraverse f g (RetType dims t) = RetType dims <$> bitraverse f g t
instance Functor (RetTypeBase dim) where
- fmap = second
+ fmap = fmapDefault
+
+instance Foldable (RetTypeBase dim) where
+ foldMap = foldMapDefault
+
+instance Traversable (RetTypeBase dim) where
+ traverse = bitraverse pure
instance Bifunctor RetTypeBase where
bimap = bimapDefault
@@ -318,7 +324,13 @@
instance Bitraversable ScalarTypeBase where
bitraverse f g (Sum cs) = Sum <$> (traverse . traverse) (bitraverse f g) cs
instance Functor (ScalarTypeBase dim) where
- fmap = second
+ fmap = fmapDefault
+
+instance Foldable (ScalarTypeBase dim) where
+ foldMap = foldMapDefault
+
+instance Traversable (ScalarTypeBase dim) where
+ traverse = bitraverse pure
instance Bifunctor ScalarTypeBase where
bimap = bimapDefault
@@ -342,7 +354,13 @@
instance Bitraversable TypeBase where
Array <$> g a <*> pure u <*> traverse f shape <*> bitraverse f pure t
instance Functor (TypeBase dim) where
- fmap = second
+ fmap = fmapDefault
+
+instance Foldable (TypeBase dim) where
+ foldMap = foldMapDefault
+
+instance Traversable (TypeBase dim) where
+ traverse = bitraverse pure
instance Bifunctor TypeBase where
bimap = bimapDefault
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment