aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Helper.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Helper.hs')
-rw-r--r--src/Helper.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Helper.hs b/src/Helper.hs
index 695d63f..3617cfc 100644
--- a/src/Helper.hs
+++ b/src/Helper.hs
@@ -20,6 +20,9 @@ import Data.Maybe ( fromMaybe
, isNothing
)
import GHC.Generics ( Generic )
+import GHC.Real ( denominator
+ , numerator
+ )
import Text.Megaparsec
invalidProgramState :: a
@@ -370,7 +373,7 @@ humanifyString :: Expression -> Maybe String
humanifyString e = do
es <- unlistify e
str <- mapM binaryToChar' es
- pure str
+ pure $ "\"" <> str <> "\""
humanifyPair :: Expression -> Maybe String
humanifyPair e = do
@@ -381,6 +384,21 @@ humanifyPair e = do
---
+floatToRational :: Rational -> Expression
+floatToRational f = Abstraction
+ (Application (Application (Bruijn 0) (decimalToTernary p))
+ (decimalToTernary $ q - 1)
+ )
+ where
+ p = numerator f
+ q = denominator f
+
+floatToReal :: Rational -> Expression
+floatToReal f = Bruijn 0
+
+floatToComplex :: Rational -> Expression
+floatToComplex f = Bruijn 0
+
-- Dec to Bal3 in Bruijn encoding: reversed application with 0=>0; 1=>1; T=>2; end=>3
-- e.g. 0=0=[[[[3]]]]; 2=1T=[[[[2 (1 3)]]]] -5=T11=[[[[1 (1 (2 3))]]]]
decimalToTernary :: Integer -> Expression