try-catch

This commit is contained in:
2024-10-04 13:29:34 +02:00
parent fb7f5c936a
commit 46aa789d64
66 changed files with 564 additions and 0 deletions

0
a4/db.txt Normal file
View File

View File

@ -0,0 +1,25 @@
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module PackageInfo_a4 (
name,
version,
synopsis,
copyright,
homepage,
) where
import Data.Version (Version(..))
import Prelude
name :: String
name = "a4"
version :: Version
version = Version [1,0,0,0] []
synopsis :: String
synopsis = ""
copyright :: String
copyright = ""
homepage :: String
homepage = ""

View File

@ -0,0 +1,77 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
#if __GLASGOW_HASKELL__ >= 810
{-# OPTIONS_GHC -Wno-prepositive-qualified-module #-}
#endif
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_a4 (
version,
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import qualified Data.List as List
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
#if defined(VERSION_base)
#if MIN_VERSION_base(4,0,0)
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#else
catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a
#endif
#else
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#endif
catchIO = Exception.catch
version :: Version
version = Version [1,0,0,0] []
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir `joinFileName` name)
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/nikolaj/.cabal/bin"
libdir = "/home/nikolaj/.cabal/lib/x86_64-linux-ghc-9.2.8/a4-1.0.0.0-inplace"
dynlibdir = "/home/nikolaj/.cabal/lib/x86_64-linux-ghc-9.2.8"
datadir = "/home/nikolaj/.cabal/share/x86_64-linux-ghc-9.2.8/a4-1.0.0.0"
libexecdir = "/home/nikolaj/.cabal/libexec/x86_64-linux-ghc-9.2.8/a4-1.0.0.0"
sysconfdir = "/home/nikolaj/.cabal/etc"
getBinDir = catchIO (getEnv "a4_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "a4_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "a4_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "a4_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "a4_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "a4_sysconfdir") (\_ -> return sysconfdir)
joinFileName :: String -> String -> FilePath
joinFileName "" fname = fname
joinFileName "." fname = fname
joinFileName dir "" = dir
joinFileName dir fname
| isPathSeparator (List.last dir) = dir ++ fname
| otherwise = dir ++ pathSeparator : fname
pathSeparator :: Char
pathSeparator = '/'
isPathSeparator :: Char -> Bool
isPathSeparator c = c == '/'

View File

@ -0,0 +1,163 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package a4-1.0.0.0 */
#ifndef VERSION_a4
#define VERSION_a4 "1.0.0.0"
#endif /* VERSION_a4 */
#ifndef MIN_VERSION_a4
#define MIN_VERSION_a4(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 0 || \
(major1) == 1 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_VERSION_a4 */
/* package base-4.16.4.0 */
#ifndef VERSION_base
#define VERSION_base "4.16.4.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 16 || \
(major1) == 4 && (major2) == 16 && (minor) <= 4)
#endif /* MIN_VERSION_base */
/* package directory-1.3.6.2 */
#ifndef VERSION_directory
#define VERSION_directory "1.3.6.2"
#endif /* VERSION_directory */
#ifndef MIN_VERSION_directory
#define MIN_VERSION_directory(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 3 || \
(major1) == 1 && (major2) == 3 && (minor) <= 6)
#endif /* MIN_VERSION_directory */
/* package process-1.6.16.0 */
#ifndef VERSION_process
#define VERSION_process "1.6.16.0"
#endif /* VERSION_process */
#ifndef MIN_VERSION_process
#define MIN_VERSION_process(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 6 || \
(major1) == 1 && (major2) == 6 && (minor) <= 16)
#endif /* MIN_VERSION_process */
/* package tasty-1.5 */
#ifndef VERSION_tasty
#define VERSION_tasty "1.5"
#endif /* VERSION_tasty */
#ifndef MIN_VERSION_tasty
#define MIN_VERSION_tasty(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 5 || \
(major1) == 1 && (major2) == 5 && (minor) <= 0)
#endif /* MIN_VERSION_tasty */
/* package tasty-hunit-0.10.2 */
#ifndef VERSION_tasty_hunit
#define VERSION_tasty_hunit "0.10.2"
#endif /* VERSION_tasty_hunit */
#ifndef MIN_VERSION_tasty_hunit
#define MIN_VERSION_tasty_hunit(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 10 || \
(major1) == 0 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_VERSION_tasty_hunit */
/* tool gcc-14.2.1 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "14.2.1"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 14 || \
(major1) == 14 && (major2) < 2 || \
(major1) == 14 && (major2) == 2 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-9.2.8 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "9.2.8"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 2 || \
(major1) == 9 && (major2) == 2 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-9.2.8 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "9.2.8"
#endif /* TOOL_VERSION_ghc_pkg */
#ifndef MIN_TOOL_VERSION_ghc_pkg
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 2 || \
(major1) == 9 && (major2) == 2 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.26.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.26.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 26 || \
(major1) == 2 && (major2) == 26 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool hpc-0.68 */
#ifndef TOOL_VERSION_hpc
#define TOOL_VERSION_hpc "0.68"
#endif /* TOOL_VERSION_hpc */
#ifndef MIN_TOOL_VERSION_hpc
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_hpc */
/* tool hsc2hs-0.68.8 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.8"
#endif /* TOOL_VERSION_hsc2hs */
#ifndef MIN_TOOL_VERSION_hsc2hs
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool pkg-config-2.1.1 */
#ifndef TOOL_VERSION_pkg_config
#define TOOL_VERSION_pkg_config "2.1.1"
#endif /* TOOL_VERSION_pkg_config */
#ifndef MIN_TOOL_VERSION_pkg_config
#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 1 || \
(major1) == 2 && (major2) == 1 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_pkg_config */
/* tool runghc-9.2.8 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "9.2.8"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 2 || \
(major1) == 9 && (major2) == 2 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_runghc */
/* tool strip-2.43 */
#ifndef TOOL_VERSION_strip
#define TOOL_VERSION_strip "2.43"
#endif /* TOOL_VERSION_strip */
#ifndef MIN_TOOL_VERSION_strip
#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 43 || \
(major1) == 2 && (major2) == 43 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_strip */
#ifndef CURRENT_PACKAGE_KEY
#define CURRENT_PACKAGE_KEY "a4-1.0.0.0-inplace"
#endif /* CURRENT_packageKey */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "a4-1.0.0.0-inplace"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "1.0.0.0"
#endif /* CURRENT_PACKAGE_VERSION */

View File

@ -0,0 +1,25 @@
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module PackageInfo_a4 (
name,
version,
synopsis,
copyright,
homepage,
) where
import Data.Version (Version(..))
import Prelude
name :: String
name = "a4"
version :: Version
version = Version [1,0,0,0] []
synopsis :: String
synopsis = ""
copyright :: String
copyright = ""
homepage :: String
homepage = ""

View File

@ -0,0 +1,77 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
#if __GLASGOW_HASKELL__ >= 810
{-# OPTIONS_GHC -Wno-prepositive-qualified-module #-}
#endif
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_a4 (
version,
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import qualified Data.List as List
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
#if defined(VERSION_base)
#if MIN_VERSION_base(4,0,0)
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#else
catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a
#endif
#else
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#endif
catchIO = Exception.catch
version :: Version
version = Version [1,0,0,0] []
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir `joinFileName` name)
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/nikolaj/.cabal/bin"
libdir = "/home/nikolaj/.cabal/lib/x86_64-linux-ghc-9.2.8/a4-1.0.0.0-inplace-a4-test"
dynlibdir = "/home/nikolaj/.cabal/lib/x86_64-linux-ghc-9.2.8"
datadir = "/home/nikolaj/.cabal/share/x86_64-linux-ghc-9.2.8/a4-1.0.0.0"
libexecdir = "/home/nikolaj/.cabal/libexec/x86_64-linux-ghc-9.2.8/a4-1.0.0.0"
sysconfdir = "/home/nikolaj/.cabal/etc"
getBinDir = catchIO (getEnv "a4_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "a4_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "a4_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "a4_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "a4_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "a4_sysconfdir") (\_ -> return sysconfdir)
joinFileName :: String -> String -> FilePath
joinFileName "" fname = fname
joinFileName "." fname = fname
joinFileName dir "" = dir
joinFileName dir fname
| isPathSeparator (List.last dir) = dir ++ fname
| otherwise = dir ++ pathSeparator : fname
pathSeparator :: Char
pathSeparator = '/'
isPathSeparator :: Char -> Bool
isPathSeparator c = c == '/'

View File

@ -0,0 +1,140 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package a4-1.0.0.0 */
#ifndef VERSION_a4
#define VERSION_a4 "1.0.0.0"
#endif /* VERSION_a4 */
#ifndef MIN_VERSION_a4
#define MIN_VERSION_a4(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 0 || \
(major1) == 1 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_VERSION_a4 */
/* package a4-1.0.0.0 */
#ifndef VERSION_a4
#define VERSION_a4 "1.0.0.0"
#endif /* VERSION_a4 */
#ifndef MIN_VERSION_a4
#define MIN_VERSION_a4(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 0 || \
(major1) == 1 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_VERSION_a4 */
/* package base-4.16.4.0 */
#ifndef VERSION_base
#define VERSION_base "4.16.4.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 16 || \
(major1) == 4 && (major2) == 16 && (minor) <= 4)
#endif /* MIN_VERSION_base */
/* package tasty-1.5 */
#ifndef VERSION_tasty
#define VERSION_tasty "1.5"
#endif /* VERSION_tasty */
#ifndef MIN_VERSION_tasty
#define MIN_VERSION_tasty(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 5 || \
(major1) == 1 && (major2) == 5 && (minor) <= 0)
#endif /* MIN_VERSION_tasty */
/* tool gcc-14.2.1 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "14.2.1"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 14 || \
(major1) == 14 && (major2) < 2 || \
(major1) == 14 && (major2) == 2 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-9.2.8 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "9.2.8"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 2 || \
(major1) == 9 && (major2) == 2 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-9.2.8 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "9.2.8"
#endif /* TOOL_VERSION_ghc_pkg */
#ifndef MIN_TOOL_VERSION_ghc_pkg
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 2 || \
(major1) == 9 && (major2) == 2 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.26.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.26.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 26 || \
(major1) == 2 && (major2) == 26 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool hpc-0.68 */
#ifndef TOOL_VERSION_hpc
#define TOOL_VERSION_hpc "0.68"
#endif /* TOOL_VERSION_hpc */
#ifndef MIN_TOOL_VERSION_hpc
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_hpc */
/* tool hsc2hs-0.68.8 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.8"
#endif /* TOOL_VERSION_hsc2hs */
#ifndef MIN_TOOL_VERSION_hsc2hs
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool pkg-config-2.1.1 */
#ifndef TOOL_VERSION_pkg_config
#define TOOL_VERSION_pkg_config "2.1.1"
#endif /* TOOL_VERSION_pkg_config */
#ifndef MIN_TOOL_VERSION_pkg_config
#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 1 || \
(major1) == 2 && (major2) == 1 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_pkg_config */
/* tool runghc-9.2.8 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "9.2.8"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 2 || \
(major1) == 9 && (major2) == 2 && (minor) <= 8)
#endif /* MIN_TOOL_VERSION_runghc */
/* tool strip-2.43 */
#ifndef TOOL_VERSION_strip
#define TOOL_VERSION_strip "2.43"
#endif /* TOOL_VERSION_strip */
#ifndef MIN_TOOL_VERSION_strip
#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 43 || \
(major1) == 2 && (major2) == 43 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_strip */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "a4-1.0.0.0-inplace-a4-test"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "1.0.0.0"
#endif /* CURRENT_PACKAGE_VERSION */

View File

@ -0,0 +1,3 @@
Test suite a4-test: RUNNING...
Test suite a4-test: PASS
Test suite logged to: /home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/t/a4-test/test/a4-1.0.0.0-a4-test.log

View File

@ -0,0 +1 @@
PackageLog {package = PackageIdentifier {pkgName = PackageName "a4", pkgVersion = mkVersion [1,0,0,0]}, compiler = CompilerId GHC (mkVersion [9,2,8]), platform = Platform X86_64 Linux, testSuites = [TestSuiteLog {testSuiteName = UnqualComponentName "a4-test", testLogs = TestLog {testName = "a4-test", testOptionsReturned = [], testResult = Pass}, logFile = "/home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/t/a4-test/test/a4-1.0.0.0-a4-test.log"}]}

BIN
a4/dist-newstyle/cache/compiler vendored Normal file

Binary file not shown.

BIN
a4/dist-newstyle/cache/config vendored Normal file

Binary file not shown.

BIN
a4/dist-newstyle/cache/elaborated-plan vendored Normal file

Binary file not shown.

BIN
a4/dist-newstyle/cache/improved-plan vendored Normal file

Binary file not shown.

1
a4/dist-newstyle/cache/plan.json vendored Normal file

File diff suppressed because one or more lines are too long

BIN
a4/dist-newstyle/cache/solver-plan vendored Normal file

Binary file not shown.

BIN
a4/dist-newstyle/cache/source-hashes vendored Normal file

Binary file not shown.

BIN
a4/dist-newstyle/cache/up-to-date vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,32 @@
name: a4
version: 1.0.0.0
visibility: public
id: a4-1.0.0.0-inplace
key: a4-1.0.0.0-inplace
abi: inplace
exposed: True
exposed-modules:
APL.AST APL.Eval APL.InterpIO APL.InterpPure APL.Interp_Tests
APL.Monad APL.Util
import-dirs:
/home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/build
library-dirs:
/home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/build
dynamic-library-dirs:
/home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/build
data-dir: /home/nikolaj/Code/KU/2024B1-AP/assignments/a4/.
hs-libraries: HSa4-1.0.0.0-inplace
depends:
base-4.16.4.0 directory-1.3.6.2 process-1.6.16.0
tasty-1.5-9c8bfa897c4bbbd45db59166bf8822fd731902e914b534b6a833c6ed622f52af
tasty-hunit-0.10.2-e3418cb0d0858b924fc6872fee2cea6b263d1c0a41eb00025dc20a99cba863f6
haddock-interfaces:
/home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/doc/html/a4/a4.haddock
haddock-html:
/home/nikolaj/Code/KU/2024B1-AP/assignments/a4/dist-newstyle/build/x86_64-linux/ghc-9.2.8/a4-1.0.0.0/doc/html/a4

Binary file not shown.

View File

@ -13,4 +13,8 @@ runEval = runEval' envEmpty stateInitial
runEval' r s (Free (PrintOp p m)) =
let (ps, res) = runEval' r s m
in (p : ps, res)
runEval' r s (Free (TryCatchOp m l)) =
case (runEval' r s m) of
(_, Left e) -> runEval' r s l
a -> a
runEval' _ _ (Free (ErrorOp e)) = ([], Left e)

View File

@ -65,6 +65,22 @@ pureTests =
--
testCase "Div0" $
eval' (Div (CstInt 7) (CstInt 0))
@?= ([], Left "Division by zero"),
--
testCase "TryCatch try1" $
eval' (TryCatch (CstInt 1) (CstInt 2))
@?= ([], Right (ValInt 1)),
--
testCase "TryCatch try2" $
eval' (TryCatch (CstInt 1) (Div (CstInt 1) (CstInt 0)))
@?= ([], Right (ValInt 1)),
--
testCase "TryCatch catch1" $
eval' (TryCatch (Div (CstInt 1) (CstInt 0)) (CstInt 1))
@?= ([], Right (ValInt 1)),
--
testCase "TryCatch catch1" $
eval' (TryCatch (Div (CstInt 1) (CstInt 0)) (Div (CstInt 1) (CstInt 0)))
@?= ([], Left "Division by zero")
]