Skip to content

Instantly share code, notes, and snippets.

@laughedelic
Forked from hodzanassredin/Prolog.hs
Created December 1, 2011 15:32
Show Gist options
  • Save laughedelic/1417595 to your computer and use it in GitHub Desktop.
Save laughedelic/1417595 to your computer and use it in GitHub Desktop.
simple type level predicates in haskell (with functional dependencies)
{-# 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