Created
December 1, 2011 10:59
-
-
Save hodzanassredin/1415832 to your computer and use it in GitHub Desktop.
simple type level predicates in haskell
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
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-} | |
module Prolog (Petja, Vasja, Serg, Father) where | |
data Petja = Petja | |
data Vasja = Vasja | |
data Serg = Serg | |
class Father a b where | |
isFather :: a -> b -> () | |
isFather x y = () | |
instance Father Vasja Petja | |
instance Father Petja Serg | |
class Son a b where | |
isSon :: a -> b -> () | |
isSon x y = () | |
instance (Father b a) => Son a b | |
class GrandFather a b c where | |
isGrandFather :: a -> c -> () | |
isGrandFather x y = () | |
instance (Father a b, Father b c) => GrandFather a b c | |
Вроде как нет. Я создавал нескольких детей и всё было ок. Даже сделал класс Brothers
")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Интересно надо будет поэкспериментировать.