Created
October 23, 2017 12:33
-
-
Save metaleap/b7848fb180faaa8e59709679e6d36768 to your computer and use it in GitHub Desktop.
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
module Mini.TCls3 (class Two, dos, class Tri, tres, class Quad, quattro) where | |
class Zero where | |
zilch :: Boolean | |
class One where | |
uno :: Int -> Number | |
ein :: Number -> Boolean -> Int | |
class One <= Two a where | |
dos :: a -> Int | |
class (Two a, Zero) <= Tri b a where | |
tres :: a -> b | |
class (Zero, Two a) <= Quad a b where | |
quattro :: b -> a | |
instance inst0 :: Zero where | |
zilch = true | |
instance inst1 :: One where | |
uno _ = 1.23 | |
ein _ true = 321 | |
ein _ _ = 123 |
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
module Mini.TClsImpl3 where | |
import Prelude ((*)) | |
import Mini.TCls3 | |
newtype NtTwo = NT2 Int | |
newtype NtTri = NT3 String | |
newtype NtFour a = NT4 a | |
instance inst2 :: Two NtTwo where | |
dos (NT2 i) = | |
i * 2 | |
instance inst3 :: Tri NtTri NtTwo where | |
tres (NT2 0) = | |
NT3 "eq-0" | |
tres _ = | |
NT3 "gt-0" | |
instance inst4 :: (Two a) => Quad a (NtFour a) where | |
quattro (NT4 a) = | |
a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment