Created
March 22, 2021 14:44
-
-
Save PPKFS/45626a1a7642afaf1817853d3b55819a to your computer and use it in GitHub Desktop.
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
-- how I can do it | |
universe = fromList $ [("cat", ["animal"]), ("dog", ["animal"]), ("catdog", ["cat", "dog"]) | |
isType x x = True | |
isType x y = case lookup universe x of | |
Nothing -> False | |
Just supertypes -> if y in supertypes then True else any (`isType` y) supertypes | |
-- "cat" `isType` "animal" True | |
-- "cat" `isType` "catdog" False | |
-- "catdog" `isType` "animal" True | |
-- "ctadog" `isType` "anmial" False, but should be a compile error.. | |
-- what I'd like to do, weird pseudocode | |
type family? Types | |
data Cat | |
data Dog | |
data CatDog | |
data Animal | |
universe = fromList $ [(Cat, [Animal]), (Dog, [Animal])... | |
Ctadog `isType` Anmial is now a typo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment