1
我有兩個either
值,例如:錯誤處理多個要麼值
Either String Config -- error string or config parsed
Either String Env -- error string or environment variables detected
而且我想他們的價值觀提取到這個紀錄:
type App = App { config :: Config, env :: Env }
而失敗快,如果有是錯誤(其中一個值爲Left
)。
我可以使用兩個case
語句,但我想知道是否已經有一個我可以在此使用的抽象了?
理想情況下,我會在出現錯誤時記錄消息並立即退出程序。
感謝。另外我用'System.Exit.die'來處理錯誤:https://github.com/srid/slownews/commit/a80134c4d918e8b258ae3f1115a62c99ae9b601f –
聽起來很對! – gallais