-
-
Save eagletmt/464078 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 ExistentialQuantification #-} | |
import System | |
class Hi_ a where | |
hi :: a -> String | |
data Hi = forall a. Hi_ a => Hi a | |
instance Hi_ Hi where | |
hi (Hi x) = hi x | |
data Ujihisa = Ujihisa | |
instance Hi_ Ujihisa where | |
hi = const "my name is ujihisa" | |
ujihisa :: Hi | |
ujihisa = Hi Ujihisa | |
data Ujm = Ujm | |
instance Hi_ Ujm where | |
hi = const "this is a pen" | |
ujm :: Hi | |
ujm = Hi Ujm | |
main = do x <- getArgs | |
let the_klass = if length x == 1 then ujihisa else ujm | |
print $ hi the_klass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment