-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from conjure-cp/remove-horizontal-sequence-rules
Remove 3 horizontal sequence rules
- Loading branch information
Showing
4 changed files
with
40 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
module Conjure.Language.RepresentationOf where | ||
|
||
-- conjure | ||
import Conjure.Prelude | ||
import Conjure.Language.Domain | ||
import Conjure.Language.Type ( TypeCheckerMode ) | ||
|
||
import Conjure.Language.Domain | ||
import Conjure.Language.Type (TypeCheckerMode) | ||
import Conjure.Prelude | ||
|
||
class RepresentationOf a where | ||
representationTreeOf | ||
:: (MonadFailDoc m, ?typeCheckerMode :: TypeCheckerMode) | ||
=> a -> m (Tree (Maybe HasRepresentation)) | ||
representationTreeOf :: | ||
(MonadFailDoc m, ?typeCheckerMode :: TypeCheckerMode) => | ||
a -> | ||
m (Tree (Maybe HasRepresentation)) | ||
|
||
representationOf :: (RepresentationOf a, MonadFailDoc m, ?typeCheckerMode :: TypeCheckerMode) => a -> m HasRepresentation | ||
representationOf a = do | ||
tree <- representationTreeOf a | ||
case rootLabel tree of | ||
Nothing -> failDoc "doesn't seem to have a representation" | ||
representationOf a = | ||
case representationTreeOf a of | ||
Nothing -> failDoc "doesn't seem to have a representation tree" | ||
Just tree -> | ||
case rootLabel tree of | ||
Nothing -> failDoc "doesn't seem to have a representation" | ||
Just NoRepresentation -> failDoc "doesn't seem to have a representation" | ||
Just r -> return r | ||
|
||
hasRepresentation :: (RepresentationOf a, MonadFailDoc m, ?typeCheckerMode :: TypeCheckerMode) => a -> m () | ||
hasRepresentation x = | ||
case representationOf x of | ||
Nothing -> failDoc "doesn't seem to have a representation" | ||
Just _ -> return () | ||
case representationTreeOf x of | ||
Nothing -> failDoc "doesn't seem to have a representation" | ||
Just _ -> return () | ||
|
||
sameRepresentation :: (RepresentationOf a, MonadFailDoc m, ?typeCheckerMode :: TypeCheckerMode) => a -> a -> m () | ||
sameRepresentation x y = | ||
case (representationOf x, representationOf y) of | ||
(Just rx, Just ry) | rx == ry -> return () | ||
_ -> failDoc "doesn't seem to have the same representation" | ||
case (representationOf x, representationOf y) of | ||
(Just rx, Just ry) | rx == ry -> return () | ||
_ -> failDoc "doesn't seem to have the same representation" | ||
|
||
sameRepresentationTree :: (RepresentationOf a, MonadFailDoc m, ?typeCheckerMode :: TypeCheckerMode) => a -> a -> m () | ||
sameRepresentationTree x y = do | ||
xTree <- representationTreeOf x | ||
yTree <- representationTreeOf y | ||
unless (xTree == yTree) $ | ||
failDoc "doesn't seem to have the same representation tree" | ||
xTree <- representationTreeOf x | ||
yTree <- representationTreeOf y | ||
unless (xTree == yTree) | ||
$ failDoc "doesn't seem to have the same representation tree" |
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