fork download
  1. {-# LANGUAGE DataKinds #-}
  2. {-# LANGUAGE FlexibleContexts #-}
  3. {-# LANGUAGE KindSignatures #-}
  4. {-# LANGUAGE TypeFamilies #-}
  5.  
  6. data Tree = Leaf | Fork Tree Tree
  7.  
  8. type family Branch (t :: Tree) (u :: Tree) :: Tree where
  9. Branch Leaf Leaf = Leaf
  10. Branch Leaf (Fork l r) = Fork (Branch l r) (Branch r l)
  11. Branch (Fork l r) u = Fork (Branch u l) (Branch u r)
  12.  
  13. type Four = Fork (Fork (Fork Leaf Leaf) (Fork Leaf Leaf)) (Fork (Fork Leaf Leaf) (Fork Leaf Leaf))
  14.  
  15. class SmthTree (t :: Tree)
  16. instance SmthTree Leaf
  17. instance (SmthTree l, SmthTree r) => SmthTree (Fork l r)
  18.  
  19. test :: SmthTree (Branch (Branch (Branch Four Four) (Branch Four Four)) (Branch (Branch Four Four) (Branch Four Four))) => ()
  20. test = ()
  21.  
  22. main = print ()
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )
stdout
Standard output is empty