aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-108/stuart-little/haskell/ch-1.hs20
-rwxr-xr-xchallenge-108/stuart-little/haskell/ch-2.hs6
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-108/stuart-little/haskell/ch-1.hs b/challenge-108/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..f74afd1560
--- /dev/null
+++ b/challenge-108/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,20 @@
+#!/usr/bin/env runghc
+
+-- run <script>
+-- ref: https://stackoverflow.com/a/18563789/11064961
+
+{-# LANGUAGE MagicHash, BangPatterns #-}
+
+import GHC.Exts
+
+data Ptr' a = Ptr' a
+
+getIntAddr :: Int -> Int
+getIntAddr x = let !y = Ptr' x in unsafeCoerce# y :: Int
+
+x :: Int
+x=5
+
+main :: IO ()
+main = do
+ putStrLn $ "The variable x has value " ++ (show x) ++ " and address " ++ (show . getIntAddr $! x) ++ "."
diff --git a/challenge-108/stuart-little/haskell/ch-2.hs b/challenge-108/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..fc211e469c
--- /dev/null
+++ b/challenge-108/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,6 @@
+#!/usr/bin/env runghc
+
+-- run <script>
+
+main = do
+ putStrLn "1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147"