Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caught should be internal #2

Open
shajra opened this issue Nov 12, 2018 · 0 comments
Open

Caught should be internal #2

shajra opened this issue Nov 12, 2018 · 0 comments

Comments

@shajra
Copy link
Owner

shajra commented Nov 12, 2018

This example shows how we can use Caught directly to bypass safety:

{-# LANGUAGE FlexibleContexts #-}


module Main where


import           Control.Exception.Checked
import           Control.Monad
import           Data.Proxy


falseSecurity :: Throws IOException e => CheckedIO e String
falseSecurity =
    throws' (Proxy :: Proxy IOException) $ readFile "no file here"

harshReality :: CheckedIO (Caught IOException e) String
harshReality = falseSecurity

-- explodes
main :: IO ()
main = void $ runChecked harshReality

This doesn't use fancy extensions that have come out since the 2009 paper Explicitly Typed Exceptions for Haskell, so the problem was there even in the original work. And this paper suggests exposing Caught to support explicitly typed user-created exception hierarchies. So in a way, we want to expose Caught as an implementation detail that can be extended. But we also want to discourage users from trying to use it directly.

So I'm thinking I'll create an “Internal” module with everything, and then re-export what's safe out in the normal module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant