mirror of
https://github.com/github/semantic.git
synced 2024-11-29 11:02:26 +03:00
Document Interpreter.hs
This commit is contained in:
parent
fe472fc60c
commit
3637bfee24
@ -20,9 +20,11 @@ import Data.Maybe
|
||||
-- | Returns whether two terms are comparable
|
||||
type Comparable a annotation = Term a annotation -> Term a annotation -> Bool
|
||||
|
||||
-- | Diff two terms, given a function that determines whether two terms can be compared.
|
||||
interpret :: (Eq a, Eq annotation) => Comparable a annotation -> Term a annotation -> Term a annotation -> Diff a annotation
|
||||
interpret comparable a b = fromMaybe (Pure $ Replace a b) $ constructAndRun comparable a b
|
||||
|
||||
-- | A hylomorphism. Given an `a`, unfold and then refold into a `b`.
|
||||
hylo :: Functor f => (t -> f b -> b) -> (a -> (t, f a)) -> a -> b
|
||||
hylo down up a = down annotation $ hylo down up <$> syntax where
|
||||
(annotation, syntax) = up a
|
||||
|
Loading…
Reference in New Issue
Block a user