-
-
Save laughedelic/1417595 to your computer and use it in GitHub Desktop.
simple type level predicates in haskell (with functional dependencies)
This file contains hidden or 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 FunctionalDependencies #-} | |
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-} | |
module Prolog (Petja, Vasja, Serg, Father, Son, GrandFather) where | |
data Petja = Petja | |
data Vasja = Vasja | |
data Serg = Serg | |
class Father f s | s -> f where | |
isFather :: f -> s -> () | |
isFather x y = () | |
instance Father Vasja Petja | |
instance Father Petja Serg | |
class Son s f | s -> f where | |
isSon :: s -> f -> () | |
isSon x y = () | |
instance (Father f s) => Son s f | |
class GrandFather g c where | |
isGrandFather :: g -> c -> () | |
isGrandFather x y = () | |
instance (Father g s, Father s c) => GrandFather g c | |
-- instance (Son c s, Son s g) => GrandFather g c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment