к

список можно заматчить не вычисляя его весь
возьмем опять foldr
foldr f z [] = z
foldr f z (x:xs) = f x (foldr f z xs)
подставим f = (:), z = []
foldr (:) [] [] = []
foldr (:) [] (x:xs) = x : foldr (:) [] xs
Size: a a a
к
к
JM
к
JM
foldr (+) 0 1:repeat 2
к
let ones = repeat (Succ Zero)
let sumOfAllOnes = foldr add Zero ones
case sumOfAllOnes of
Succ (Succ x) -> print ">= 2"
">= 2"
JM
let ones = repeat (Succ Zero)
let sumOfAllOnes = foldr add Zero ones
case sumOfAllOnes of
Succ (Succ x) -> print ">= 2"
">= 2"
к
к
к
AP
AP
A
AK
cabal-version: >=1.10
-- Initial package description 'test0003.cabal' generated by 'cabal init'.
-- For further documentation, see http://haskell.org/cabal/users-guide/
name: test0003
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file: LICENSE
author: Aleksey Kislitsa
maintainer: aleksey.kislitsa@gmail.com
-- copyright:
-- category:
build-type: Simple
extra-source-files: CHANGELOG.md
library
exposed-modules: Lib
-- other-modules: Paths_test0003
hs-source-dirs: src
build-depends: base >=4.13 && <4.14
-- default-language: Haskell2010
executable test0003
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.13 && <4.14, test0003
hs-source-dirs: app
default-language: Haskell2010
cabal-version: >=1.10
-- Initial package description 'test0003.cabal' generated by 'cabal init'.
-- For further documentation, see http://haskell.org/cabal/users-guide/
name: test0003
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file: LICENSE
author: Aleksey Kislitsa
maintainer: aleksey.kislitsa@gmail.com
-- copyright:
-- category:
build-type: Simple
extra-source-files: CHANGELOG.md
library
exposed-modules: Lib
-- other-modules: Paths_test0003
hs-source-dirs: src
build-depends: base >=4.13 && <4.14
-- default-language: Haskell2010
executable test0003
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.13 && <4.14, test0003
hs-source-dirs: app, src
default-language: Haskell2010
AK
AP
cabal-version: >=1.10
-- Initial package description 'test0003.cabal' generated by 'cabal init'.
-- For further documentation, see http://haskell.org/cabal/users-guide/
name: test0003
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file: LICENSE
author: Aleksey Kislitsa
maintainer: aleksey.kislitsa@gmail.com
-- copyright:
-- category:
build-type: Simple
extra-source-files: CHANGELOG.md
library
exposed-modules: Lib
-- other-modules: Paths_test0003
hs-source-dirs: src
build-depends: base >=4.13 && <4.14
-- default-language: Haskell2010
executable test0003
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.13 && <4.14, test0003
hs-source-dirs: app
default-language: Haskell2010
cabal-version: >=1.10
-- Initial package description 'test0003.cabal' generated by 'cabal init'.
-- For further documentation, see http://haskell.org/cabal/users-guide/
name: test0003
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file: LICENSE
author: Aleksey Kislitsa
maintainer: aleksey.kislitsa@gmail.com
-- copyright:
-- category:
build-type: Simple
extra-source-files: CHANGELOG.md
library
exposed-modules: Lib
-- other-modules: Paths_test0003
hs-source-dirs: src
build-depends: base >=4.13 && <4.14
-- default-language: Haskell2010
executable test0003
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.13 && <4.14, test0003
hs-source-dirs: app, src
default-language: Haskell2010
AP
AP
AP
cabal run
. Вот вам и будет "запуск"AP