Last active
March 21, 2018 21:22
-
-
Save li-boxuan/8dd7a1a07b803e5d9b3b5d4fa998260f to your computer and use it in GitHub Desktop.
test sample for part one
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
Step 1. | |
Build a valid example and an invalid example separately. (why the latter one is invalid?) | |
> valid_example = unify (Function [TypeVar "s1", TypeVar "s2", TypeVar "s3"] (TypeVar "s3")) (Function [Bool_, TypeVar "s4", Int_] Int_) | |
> invalid_example = unify (Function [TypeVar "s1", TypeVar "s2", TypeVar "s3"] (TypeVar "s3")) (Function [Bool_, TypeVar "s4", Int_] Bool_) | |
Step 2. | |
Test the consolidate function | |
> valid_example >>= consolidate | |
Just (fromList [(TypeVar "s1",Bool_),(TypeVar "s2",TypeVar "s4"),(TypeVar "s3",Int_)]) | |
> invalid_example >>= consolidate | |
Nothing | |
Step 3. | |
Test the resolve function | |
> resolve_helper (Just constraints) = resolve constraints | |
> resolve_helper (valid_example >>= consolidate) (TypeVar "s1") | |
Bool_ | |
> resolve_helper (valid_example >>= consolidate) (TypeVar "s2") | |
TypeVar "s4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment