blob: cb95b278ceefb2b3f7d2168cbe88c1f608589098 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
{-# LANGUAGE DeriveFoldable #-}
module Main where
import Data.Semigroup
-- Just a list without any special fusion rules.
data List a = Nil | Cons a (List a) deriving Foldable
instance Semigroup (List a) where
Nil <> ys = ys
Cons x xs <> ys = Cons x (xs <> ys)
replicateList :: Int -> a -> List a
replicateList 0 x = Nil
replicateList n x = Cons x (replicateList (n - 1) x)
newtype ListList a = ListList (List (List a)) deriving Foldable
long :: Int -> Bool
long n = null $ ListList $ replicateList n Nil <> Cons (Cons () Nil) Nil
main :: IO ()
main = print $ long (10^(6 :: Int))
|