Created
          October 18, 2015 05:38 
        
      - 
      
- 
        Save myuon/e2b977c452a21d8f3fe0 to your computer and use it in GitHub Desktop. 
  
    
      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 TypeFamilies, DataKinds, TypeOperators, FlexibleInstances #-} | |
| import GHC.TypeLits | |
| type family FuncType (as :: [*]) where | |
| FuncType '[] = IO () | |
| FuncType (a ': as) = a -> FuncType as | |
| data Name (s :: Symbol) = Name | |
| data FullOption = FullOption { | |
| opt1 :: Int, | |
| opt2 :: String, | |
| opt3 :: [Int] | |
| } deriving (Eq, Show) | |
| class Hoge (s :: Symbol) where | |
| type Arg :: [*] | |
| hoge :: Name s -> FuncType Arg | |
| hogeFullOption :: Name s -> FullOption -> IO () | |
| hogeFullOption _ opt = print opt | |
| instance Hoge "this" where | |
| type Arg = [Int, Char] | |
| hoge _ n c = putStrLn $ "int: " ++ show n ++ " char: " ++ show c | |
| this = hoge (Name :: Name "this") | |
| main = do | |
| this 10 '#' | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment