refactor for boolean blindness

This commit is contained in:
Lucy Cifferello
2020-07-07 17:38:17 -06:00
parent bce11215d3
commit 7232c48292
5 changed files with 32 additions and 14 deletions

View File

@@ -55,3 +55,8 @@ handleS9ErrNuclear :: MonadIO m => S9ErrT m a -> m a
handleS9ErrNuclear action = runExceptT action >>= \case
Left e -> throwIO e
Right a -> pure a
errOnNothing :: MonadHandler m => Status -> Text -> Maybe a -> m a
errOnNothing status res entity = case entity of
Nothing -> sendResponseStatus status res
Just a -> pure a

View File

@@ -16,6 +16,7 @@ import Yesod.Core
import Lib.Semver
import Lib.Types.Semver
import Data.Char
type Registry = HashMap String (HashMap AppVersion FilePath)
@@ -50,6 +51,11 @@ type S9PK = Extension "s9pk"
type SYS_EXTENSIONLESS = Extension ""
type PNG = Extension "png"
data Extensions = S9PK | PNG | EMPTY
deriving (Read)
instance Show Extensions where
show a = fmap toLower $ show a
instance IsString (Extension a) where
fromString = Extension

View File

@@ -0,0 +1,6 @@
module Lib.Types.FileSystem where
import Startlude
data FileExistence = Existent | NonExistent
deriving (Eq, Show)