-- m は暗黙に量化されている
{-
action :: forall m. MonadError OutOfRange m => m Int
-}
action :: MonadError OutOfRange m => m Int
action = undefined
foo :: Either OutOfRange Int -> Either OutOfRange Int -> Either OutOfRange Int
foo = undefined
result :: Either OutOfRange Int
result = foo (_hole action) (_bar action)
-- _hole の型は、ユニフィケーション変数m1を使って
-- _hole :: m1 Int -> Either OutOfRange Int
-- _bar の型は、ユニフィケーション変数m2を使って
-- _bar :: m2 Int -> Either OutOfRange Int
--
{-# LANGUAGE ScopedTypeVaraibles #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
foo :: Either OutOfRange Int -> Either OutOfRange Int -> Either OutOfRange Int
foo = undefined
result :: forall m. MonadError OutOfRange m => Either OutOfRange Int
result = foo (_hole action) (bar action)
where
action :: m Int
action = undefined
bar :: m Int -> Either OutOfRange Int
bar = undefined
{-# LANGUAGE ExplicitForall #-}
{-# LANGUAGE MonoLocalBinds #-}
foo :: Either OutOfRange Int -> Either OutOfRange Int -> Either OutOfRange Int
foo = undefined
genericAction :: forall m. MonadError OutOfRange m => m Int
genericFoo :: forall m. m Int -> Either OutOfRange Int
result :: Either OutOfRange Int
result = foo (_hole action) (bar action)
where
-- m はユニフィケーション変数
-- action :: m Int
action = genericAction
-- bar :: m Int -> Either OutOfRange Int
bar = genericFoo