Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
これは多相再帰型が一般には推論できないみたいな話なのか
data T = A | B | C T
deriving (Show, Eq)
class HasT a where
t :: a -> T
instance HasT T where
t = id
instance HasT a => HasT (Maybe a) where
t Nothing = B
t (Just x) = t x
-- f :: T -> Bool と型推論される
-- f :: HasT a => a -> Bool と注釈を付けることもできる
-- 多相再帰?
f x =
case t x of
A -> True
B -> False
C t' -> f t'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.