Open mhitza opened 1 month ago
I've played around with switching foldl to foldr, changing to strict Maps and such, but in the end what worked was to make the result itself strict before the handle is closed
diff --git a/hackage/MissingH-1.6.0.1/src/Data/MIME/Types.hs b/hackage/MissingH-1.6.0.1/src/Data/MIME/Types.hs
index ecdfd03..cc16134 100644
--- a/hackage/MissingH-1.6.0.1/src/Data/MIME/Types.hs
+++ b/hackage/MissingH-1.6.0.1/src/Data/MIME/Types.hs
@@ -18,6 +18,7 @@ Utilities for guessing MIME types of files.
Written by John Goerzen, jgoerzen\@complete.org
-}
+{-# LANGUAGE BangPatterns #-}
module Data.MIME.Types (-- * Creating Lookup Objects
defaultmtd,
readMIMETypes,
@@ -190,7 +191,7 @@ readSystemMIMETypes mtd =
case fn of
Left (_ :: Control.Exception.IOException) -> return inputobj
Right h -> do
- x <- hReadMIMETypes inputobj True h
+ !x <- hReadMIMETypes inputobj True h
hClose h
return x
in
I'm wrapping the initialization of the
Data.MIME.Types.guessType
call with the following functionAnd I'm calling the function in a wai + warp context, where I get the exception in the issue title.
I'm no expert in laziness, or Lazy IO for that matter, but if I where to guess it's because the underlying functions use
foldl
s without any strictness in the accumulator.