Skip to content

Instantly share code, notes, and snippets.

@cieplak
Forked from hodzanassredin/Prolog.hs
Created August 22, 2018 21:22
Show Gist options
  • Save cieplak/0295b3ebcdf5d59c4407e296fa1cf1b7 to your computer and use it in GitHub Desktop.
Save cieplak/0295b3ebcdf5d59c4407e296fa1cf1b7 to your computer and use it in GitHub Desktop.
simple type level predicates in haskell
{-# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment