Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
patches-class
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
patches-class
Commits
4cfffbab
Unverified
Commit
4cfffbab
authored
Nov 15, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change Replace semantics
parent
fcdc6dcc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
Class.hs
src/Data/Patch/Class.hs
+17
-1
No files found.
src/Data/Patch/Class.hs
View file @
4cfffbab
...
...
@@ -192,11 +192,27 @@ instance Eq a => Composable (Replace a) where
composable
(
Replace
_
n
)
(
Replace
o
_
)
=
check
(
n
==
o
)
"Composing two @Replace@ patches with a different inner value"
{- Two semantics are possible for the `Replace old new` patch:
(1) The patch is assumed to only be used on a source which is known
to be equal to `old`.
(2) The patch only replaces `old` by `new` when the source is equal to `old` and
leaves it unchanged otherwise.
Here we choose (2).
-}
instance
Eq
a
=>
Action
(
Replace
a
)
a
where
act
Keep
a
=
a
act
(
Replace
old
new
)
source
|
source
==
old
=
new
|
otherwise
=
source
{- PRODUCTION instance for semantics (1)
instance Action (Replace a) a where
act Keep a = a
act (Replace _ n) _ = n
-}
{- DEBUGGING instance
{- DEBUGGING instance
for semantics (1)
instance (Show a, Eq a) => Action (Replace a) a where
act Keep a = a
act p@(Replace expected n) found
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment