ATuin

Untitled

Jul 2nd, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  case res of
  2.         Right (Right out) -> do
  3.           verbosePut config $ "Compiled " ++ hsRelativePath f
  4.           writeFile (jsPath config f) out
  5.           return $ Success out
  6.         Right (Left err) -> do
  7.           let errString = "snaplet-fay: Error compiling " ++ hsRelativePath f ++ ":\n" ++ show err
  8.          -- putStrLn $ C.unpack (A.encode (C.pack $ escape errString))
  9.           putStrLn $ escape errString
  10.           -- return Success so the browser will treat this as a normal JavaScript file.
  11.           -- As of writing this, this means that Error is not used.
  12.           return $ Success $ "console.error('" ++ (C.unpack . A.encode) (escape errString) ++ "');"
  13.         Left err -> do
  14.           let errString = "snaplet-fay: Error compiling " ++ hsRelativePath f ++ ":\n" ++ show err
  15.           putStrLn $ escape errString
  16.           -- return Success so the browser will treat this as a normal JavaScript file.
  17.           -- As of writing this, this means that Error is not used.
  18.           return $ Success $ "console.error('" ++ (C.unpack . A.encode) (escape $ errString) ++ "');"
  19.         where
  20.           escape s = T.unpack $ T.replace (T.pack "'") (T.pack "\'") (T.pack s)
Advertisement
Add Comment
Please, Sign In to add comment