can't do this! killing myself tonight ‼️ here's three lines of code i spent four hours on

This commit is contained in:
crumbtoo
2023-11-08 19:21:12 -07:00
parent 2504f91572
commit 2e76a54585
40 changed files with 116 additions and 441 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
./dist-newstyle
dist-newstyle/

View File

@@ -1,74 +0,0 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_rlp (
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 [0,1,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 = "/Users/crumble/.cabal/bin"
libdir = "/Users/crumble/.cabal/lib/x86_64-osx-ghc-9.6.2/rlp-0.1.0.0-inplace"
dynlibdir = "/Users/crumble/.cabal/lib/x86_64-osx-ghc-9.6.2"
datadir = "/Users/crumble/.cabal/share/x86_64-osx-ghc-9.6.2/rlp-0.1.0.0"
libexecdir = "/Users/crumble/.cabal/libexec/x86_64-osx-ghc-9.6.2/rlp-0.1.0.0"
sysconfdir = "/Users/crumble/.cabal/etc"
getBinDir = catchIO (getEnv "rlp_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "rlp_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "rlp_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "rlp_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "rlp_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "rlp_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

@@ -1,123 +0,0 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package rlp-0.1.0.0 */
#ifndef VERSION_rlp
#define VERSION_rlp "0.1.0.0"
#endif /* VERSION_rlp */
#ifndef MIN_VERSION_rlp
#define MIN_VERSION_rlp(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 1 || \
(major1) == 0 && (major2) == 1 && (minor) <= 0)
#endif /* MIN_VERSION_rlp */
/* package base-4.18.0.0 */
#ifndef VERSION_base
#define VERSION_base "4.18.0.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 18 || \
(major1) == 4 && (major2) == 18 && (minor) <= 0)
#endif /* MIN_VERSION_base */
/* tool gcc-14.0.0 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "14.0.0"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 14 || \
(major1) == 14 && (major2) < 0 || \
(major1) == 14 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-9.6.2 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "9.6.2"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 6 || \
(major1) == 9 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-9.6.2 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "9.6.2"
#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) < 6 || \
(major1) == 9 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.28.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.28.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 28 || \
(major1) == 2 && (major2) == 28 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool happy-1.20.1.1 */
#ifndef TOOL_VERSION_happy
#define TOOL_VERSION_happy "1.20.1.1"
#endif /* TOOL_VERSION_happy */
#ifndef MIN_TOOL_VERSION_happy
#define MIN_TOOL_VERSION_happy(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 20 || \
(major1) == 1 && (major2) == 20 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_happy */
/* 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.9 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.9"
#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) <= 9)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool pkg-config-0.29.2 */
#ifndef TOOL_VERSION_pkg_config
#define TOOL_VERSION_pkg_config "0.29.2"
#endif /* TOOL_VERSION_pkg_config */
#ifndef MIN_TOOL_VERSION_pkg_config
#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 29 || \
(major1) == 0 && (major2) == 29 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_pkg_config */
/* tool runghc-9.6.2 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "9.6.2"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 6 || \
(major1) == 9 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_runghc */
#ifndef CURRENT_PACKAGE_KEY
#define CURRENT_PACKAGE_KEY "rlp-0.1.0.0-inplace"
#endif /* CURRENT_packageKey */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "rlp-0.1.0.0-inplace"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "0.1.0.0"
#endif /* CURRENT_PACKAGE_VERSION */

View File

@@ -1,74 +0,0 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_rlp (
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 [0,1,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 = "/Users/crumble/.cabal/bin"
libdir = "/Users/crumble/.cabal/lib/x86_64-osx-ghc-9.6.2/rlp-0.1.0.0-inplace-rlpc"
dynlibdir = "/Users/crumble/.cabal/lib/x86_64-osx-ghc-9.6.2"
datadir = "/Users/crumble/.cabal/share/x86_64-osx-ghc-9.6.2/rlp-0.1.0.0"
libexecdir = "/Users/crumble/.cabal/libexec/x86_64-osx-ghc-9.6.2/rlp-0.1.0.0"
sysconfdir = "/Users/crumble/.cabal/etc"
getBinDir = catchIO (getEnv "rlp_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "rlp_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "rlp_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "rlp_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "rlp_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "rlp_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

@@ -1,130 +0,0 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package rlp-0.1.0.0 */
#ifndef VERSION_rlp
#define VERSION_rlp "0.1.0.0"
#endif /* VERSION_rlp */
#ifndef MIN_VERSION_rlp
#define MIN_VERSION_rlp(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 1 || \
(major1) == 0 && (major2) == 1 && (minor) <= 0)
#endif /* MIN_VERSION_rlp */
/* package base-4.18.0.0 */
#ifndef VERSION_base
#define VERSION_base "4.18.0.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 18 || \
(major1) == 4 && (major2) == 18 && (minor) <= 0)
#endif /* MIN_VERSION_base */
/* package rlp-0.1.0.0 */
#ifndef VERSION_rlp
#define VERSION_rlp "0.1.0.0"
#endif /* VERSION_rlp */
#ifndef MIN_VERSION_rlp
#define MIN_VERSION_rlp(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 1 || \
(major1) == 0 && (major2) == 1 && (minor) <= 0)
#endif /* MIN_VERSION_rlp */
/* tool gcc-14.0.0 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "14.0.0"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 14 || \
(major1) == 14 && (major2) < 0 || \
(major1) == 14 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-9.6.2 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "9.6.2"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 6 || \
(major1) == 9 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-9.6.2 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "9.6.2"
#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) < 6 || \
(major1) == 9 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.28.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.28.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 28 || \
(major1) == 2 && (major2) == 28 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool happy-1.20.1.1 */
#ifndef TOOL_VERSION_happy
#define TOOL_VERSION_happy "1.20.1.1"
#endif /* TOOL_VERSION_happy */
#ifndef MIN_TOOL_VERSION_happy
#define MIN_TOOL_VERSION_happy(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 20 || \
(major1) == 1 && (major2) == 20 && (minor) <= 1)
#endif /* MIN_TOOL_VERSION_happy */
/* 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.9 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.9"
#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) <= 9)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool pkg-config-0.29.2 */
#ifndef TOOL_VERSION_pkg_config
#define TOOL_VERSION_pkg_config "0.29.2"
#endif /* TOOL_VERSION_pkg_config */
#ifndef MIN_TOOL_VERSION_pkg_config
#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 29 || \
(major1) == 0 && (major2) == 29 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_pkg_config */
/* tool runghc-9.6.2 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "9.6.2"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 6 || \
(major1) == 9 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_runghc */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "rlp-0.1.0.0-inplace-rlpc"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "0.1.0.0"
#endif /* CURRENT_PACKAGE_VERSION */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +0,0 @@
{"cabal-version":"3.8.1.0","cabal-lib-version":"3.8.1.0","compiler-id":"ghc-9.6.2","os":"osx","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.18.0.0","pkg-name":"base","pkg-version":"4.18.0.0","depends":["ghc-bignum-1.3","ghc-prim-0.10.0","rts-1.0.2"]},{"type":"pre-existing","id":"ghc-bignum-1.3","pkg-name":"ghc-bignum","pkg-version":"1.3","depends":["ghc-prim-0.10.0"]},{"type":"pre-existing","id":"ghc-prim-0.10.0","pkg-name":"ghc-prim","pkg-version":"0.10.0","depends":["rts-1.0.2"]},{"type":"configured","id":"rlp-0.1.0.0-inplace","pkg-name":"rlp","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/Users/crumble/Documents/school/CSA/rlp/."},"dist-dir":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0","build-info":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/build-info.json","depends":["base-4.18.0.0"],"exe-depends":[],"component-name":"lib"},{"type":"configured","id":"rlp-0.1.0.0-inplace-rlp-test","pkg-name":"rlp","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/Users/crumble/Documents/school/CSA/rlp/."},"dist-dir":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/t/rlp-test","build-info":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/t/rlp-test/build-info.json","depends":["base-4.18.0.0","rlp-0.1.0.0-inplace"],"exe-depends":[],"component-name":"test:rlp-test","bin-file":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/t/rlp-test/build/rlp-test/rlp-test"},{"type":"configured","id":"rlp-0.1.0.0-inplace-rlpc","pkg-name":"rlp","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/Users/crumble/Documents/school/CSA/rlp/."},"dist-dir":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/x/rlpc","build-info":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/x/rlpc/build-info.json","depends":["base-4.18.0.0","rlp-0.1.0.0-inplace"],"exe-depends":[],"component-name":"exe:rlpc","bin-file":"/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/x/rlpc/build/rlpc/rlpc"},{"type":"pre-existing","id":"rts-1.0.2","pkg-name":"rts","pkg-version":"1.0.2","depends":[]}]}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,32 +0,0 @@
name: rlp
version: 0.1.0.0
visibility: public
id: rlp-0.1.0.0-inplace
key: rlp-0.1.0.0-inplace
license: GPL-2.0-only
maintainer: crumb@disroot.org
author: crumbtoo
category: Language
abi: inplace
exposed: True
exposed-modules: Core
import-dirs:
/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/build
library-dirs:
/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/build
library-dirs-static:
/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/build
dynamic-library-dirs:
/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/build
data-dir: /Users/crumble/Documents/school/CSA/rlp/.
hs-libraries: HSrlp-0.1.0.0-inplace
depends: base-4.18.0.0
haddock-interfaces:
/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/doc/html/rlp/rlp.haddock
haddock-html:
/Users/crumble/Documents/school/CSA/rlp/dist-newstyle/build/x86_64-osx/ghc-9.6.2/rlp-0.1.0.0/doc/html/rlp

View File

@@ -14,14 +14,16 @@ extra-doc-files: README.md
-- extra-source-files:
common warnings
ghc-options: -Wall
-- ghc-options: -Wall
library
import: warnings
exposed-modules: Core
, TI
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.0.0
, containers
hs-source-dirs: src
default-language: GHC2021

View File

@@ -1,14 +1,67 @@
{-# LANGUAGE PatternSynonyms #-}
module Core where
----------------------------------------------------------------------------------
import Data.Coerce
----------------------------------------------------------------------------------
data Expr = Let Rec [Binding] Expr
| Case Expr [Alt]
data Expr = Var Name
| Con Int Int
| Let Rec [Binding] Expr
| Case Expr [Alter]
| Lam [Name] Expr
| App Expr Expr
| IntP Int
data Binding
infixl 2 :$
pattern (:$) :: Expr -> Expr -> Expr
pattern f :$ x = App f x
data Rec
data Binding = Binding Name Expr
data Alt
infixl 1 :=
pattern (:=) :: Name -> Expr -> Binding
pattern k := v = Binding k v
data Rec = Rec
| NonRec
data Alter = Alter Int [Name] Expr
type Name = String
data ScDef = ScDef Name [Name] Expr
newtype Program = Program [ScDef]
----------------------------------------------------------------------------------
instance Semigroup Program where
(<>) = coerce $ (++) @ScDef
instance Monoid Program where
mempty = Program []
----------------------------------------------------------------------------------
bindersOf :: [(Name, b)] -> [Name]
bindersOf = fmap fst
rhssOf :: [(Name, b)] -> [b]
rhssOf = fmap snd
isAtomic :: Expr -> Bool
isAtomic (Var _) = True
isAtomic _ = False
----------------------------------------------------------------------------------
corePrelude :: Program
corePrelude = Program
[ ScDef "id" ["x"] (Var "x")
, ScDef "K" ["x", "y"] (Var "x")
, ScDef "K1" ["x", "y"] (Var "y")
, ScDef "S" ["f", "g", "x"] (Var "f" :$ Var "x" :$ (Var "g" :$ Var "x"))
, ScDef "compose" ["f", "g", "x"] (Var "f" :$ (Var "g" :$ Var "x"))
, ScDef "twice" ["f", "g", "x"] (Var "f" :$ (Var "g" :$ Var "x"))
]

54
src/TI.hs Normal file
View File

@@ -0,0 +1,54 @@
module TI where
----------------------------------------------------------------------------------
import Data.Map (Map, (!?), (!))
import qualified Data.Map as M
import Data.Set (Set)
import qualified Data.Set as S
import Data.Maybe (fromJust)
import Data.List (mapAccumL)
import Core
----------------------------------------------------------------------------------
data TiState = TiState [Addr] Dump Heap [(Name, Addr)] Stats
type Heap = Set Node
data Node = NAp Addr Addr
| NSupercomb Name [Name] Expr
| NNum Int
data Dump = DumpTempDummy
type Stats = Int
type Addr = Int
----------------------------------------------------------------------------------
tiStatIncSteps :: Stats -> Stats
tiStatIncSteps = (+1)
tiStatGetSteps :: Stats -> Int
tiStatGetSteps = id
----------------------------------------------------------------------------------
compile :: Program -> Maybe TiState
compile prog = Just $ TiState s d h g stats
where
s = [mainAddr]
d = DumpTempDummy
(h,g) = buildInitialHeap defs
defs = prog <> corePrelude
stats = undefined
mainAddr = fromJust $ lookup "main" g
buildInitialHeap :: Program -> (Heap, [(Name, Addr)])
buildInitialHeap = undefined
-- buildInitialHeap (Program scdefs) = mapAccumL allocateSc mempty scdefs
-- where
-- allocateSc :: Heap -> ScDef -> (Heap, (Name, Addr))
-- allocateSc = undefined