You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--| Either a, or b, or both a and bdataSearchResultab=Scanneda | Foundb | ScannedAndFoundab--| Accumulate 'a's from left to right, until one 'b' is foundinstanceSemigroupa=>Semigroup (SearchResultab) whereScannedAndFound a b <> _ =ScannedAndFound a b
Found b <> _ =Found b
Scanned a <>Scanned a' =Scanned (a <> a')
Scanned a <>Found b =ScannedAndFound a b
Scanned a <>ScannedAndFound a' b =ScannedAndFound (a <> a') b
The type definition is identical to These, but the Semigroup semantics differ. Do you think it could/should be integrated to these library, e.g. as a newtype over These ?
Rationale: as the name suggests, this type is useful in search algorithms to return both the search result and a semigroup of traversed items.
The text was updated successfully, but these errors were encountered:
This is different from These a (First b) as This part turns into First too, when there is first That found. In current form it's a bit ad-hoc, I wonder if it can be generalised
phadej
changed the title
Alternate Semigroup instance
Alternate Semigroup instance: SearchResult
Jan 26, 2019
Consider the following data type:
The type definition is identical to
These
, but theSemigroup
semantics differ. Do you think it could/should be integrated tothese
library, e.g. as a newtype overThese
?Rationale: as the name suggests, this type is useful in search algorithms to return both the search result and a semigroup of traversed items.
The text was updated successfully, but these errors were encountered: