{-# LANGUAGE TypeFamilies #-}
class ProjResult a where
instance ProjResult
Int where projection
_ = error "index too large" constant x = x
instance (ProjResult a
, arg
~ Int) => ProjResult
(arg
-> a
) where projection 0 x = constant x
projection n _ = projection (n-1)
constant j _ = constant j
p = projection
main = do
print (projection
2 1 2 3 :: Int) -- 型注釈はこれだけでいい
ey0jIExBTkdVQUdFIFR5cGVGYW1pbGllcyAjLX0KCmNsYXNzIFByb2pSZXN1bHQgYSB3aGVyZQogIHByb2plY3Rpb24gOjogSW50IC0+IGEKICBjb25zdGFudCA6OiBJbnQgLT4gYQoKaW5zdGFuY2UgUHJvalJlc3VsdCBJbnQgd2hlcmUKICBwcm9qZWN0aW9uIF8gPSBlcnJvciAiaW5kZXggdG9vIGxhcmdlIgogIGNvbnN0YW50IHggPSB4CgppbnN0YW5jZSAoUHJvalJlc3VsdCBhLCBhcmcgfiBJbnQpID0+IFByb2pSZXN1bHQgKGFyZyAtPiBhKSB3aGVyZQogIHByb2plY3Rpb24gMCB4ID0gY29uc3RhbnQgeAogIHByb2plY3Rpb24gbiBfID0gcHJvamVjdGlvbiAobi0xKQogIGNvbnN0YW50IGogXyA9IGNvbnN0YW50IGoKCnAgOjogSW50IC0+IEludCAtPiBJbnQgLT4gSW50IC0+IEludApwID0gcHJvamVjdGlvbgoKbWFpbiA9IGRvCiAgcHJpbnQgJCBwIDIgMSAyIDMKICBwcmludCAocHJvamVjdGlvbiAyIDEgMiAzIDo6IEludCkgLS0g5Z6L5rOo6YeI44Gv44GT44KM44Gg44GR44Gn44GE44GECg==