Add remaining haskell book exercises

This commit is contained in:
2025-12-11 10:28:11 +01:00
parent 3624c712d7
commit 98329e0a3d
221 changed files with 8033 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
{-# LANGUAGE Strict #-}
module BottomExpression where
!x = undefined
y = "blah"
main = do
print $ snd $ seq x (x, y)

View File

@@ -0,0 +1,20 @@
{-# LANGUAGE Strict #-}
module StrictList where
data List a =
Nil
| Cons ~a ~(List a)
deriving (Show)
take' n _ | n <= 0 = Nil
take' _ Nil = Nil
take' n (Cons x xs) = (Cons x (take' (n - 1) xs))
map' _ Nil = Nil
map' f (Cons x xs) = (Cons (f x) (map' f xs))
repeat' x = xs where xs = (Cons x xs)
main = do
print $ take' 10 $ map' (+1) (repeat' 1)