-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
240 additions
and
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE BlockArguments #-} | ||
|
||
module Elaboration.Depth where | ||
|
||
import qualified Core.Domain as Domain | ||
import Monad | ||
import Protolude | ||
import qualified Query | ||
import qualified Query.Mapped as Mapped | ||
import Rock | ||
|
||
-- | Try to find out which of two heads might refer to the other so we can | ||
-- unfold glued values that are defined later first (see "depth" in | ||
-- https://arxiv.org/pdf/1505.04324.pdf). | ||
compareHeadDepths :: Domain.Head -> Domain.Head -> M Ordering | ||
compareHeadDepths head1 head2 = | ||
case (head1, head2) of | ||
(Domain.Global global1, Domain.Global global2) -> do | ||
global1DependsOn2 <- fetch $ Query.TransitiveDependencies global2 $ Mapped.Query global1 | ||
global2DependsOn1 <- fetch $ Query.TransitiveDependencies global1 $ Mapped.Query global2 | ||
pure case (global1DependsOn2, global2DependsOn1) of | ||
(Just _, Nothing) -> GT | ||
(Nothing, Just _) -> LT | ||
_ -> EQ | ||
(_, Domain.Global _) -> pure LT | ||
(Domain.Global _, _) -> pure GT | ||
(Domain.Var v1, Domain.Var v2) -> pure $ compare v1 v2 | ||
_ -> pure EQ |
Oops, something went wrong.