<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://ocw.cs.pub.ro/ppcarte/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://ocw.cs.pub.ro/ppcarte/feed.php">
        <title>books pp:2023:haskell</title>
        <description></description>
        <link>https://ocw.cs.pub.ro/ppcarte/</link>
        <image rdf:resource="https://ocw.cs.pub.ro/ppcarte/lib/tpl/bootstrap3/images/favicon.ico" />
       <dc:date>2026-05-20T18:07:42+03:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs09&amp;rev=1682508339&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs10&amp;rev=1682508395&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs11&amp;rev=1682508460&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs12&amp;rev=1683113045&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs13&amp;rev=1684844434&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs14&amp;rev=1684844483&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l07-extra&amp;rev=1712676774&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l07&amp;rev=1682547445&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l08&amp;rev=1682693033&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l08_2&amp;rev=1682594162&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l09&amp;rev=1683054956&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l10&amp;rev=1684167312&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://ocw.cs.pub.ro/ppcarte/lib/tpl/bootstrap3/images/favicon.ico">
        <title>books</title>
        <link>https://ocw.cs.pub.ro/ppcarte/</link>
        <url>https://ocw.cs.pub.ro/ppcarte/lib/tpl/bootstrap3/images/favicon.ico</url>
    </image>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs09&amp;rev=1682508339&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-04-26T14:25:39+03:00</dc:date>
        <title>pp:2023:haskell:curs09</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs09&amp;rev=1682508339&amp;do=diff</link>
        <description>Curs 09. Introducere in Haskell


x = 1

f :: Int -&gt; Int -&gt; Int
f x y = x * y

g = f 1

f1 :: (Int -&gt; Int) -&gt; Int
f1 x = (x 1) + 1


-- signatura unei functii nu e obligatorie
h :: a -&gt; a
h x = x

{-
def f[A](x: A): A = x 

x =&gt; x
-}

{- compunerea de functii -}
comp :: (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c 
comp f g x = f (g x)
--comp f g = \x -&gt; f (g x)

{-
\x -&gt; \y -&gt; x + y   // functie anonima (lambda) in forma curry
\x y -&gt; x + y       // forma uncurry (identica cu cea de sus)

-}

positive :: Int…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs10&amp;rev=1682508395&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-04-26T14:26:35+03:00</dc:date>
        <title>pp:2023:haskell:curs10</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs10&amp;rev=1682508395&amp;do=diff</link>
        <description>C10. Evaluare lenesa in Haskell


 {-
   In Haskell evaluarea este lazy

 -}
ones :: [Int]
ones = 1:ones

-- axioma pt take: take n (x:xs) = x:(take (n-1) xs)
{-
  take 2 ones
  take 2 (1:ones)
  1:take 1 ones
  1:take 1 (1:ones)
  1:1:take 0 ones
  1:1:[]

-}
call = foldr (&amp;&amp;) True [True,False,False,False,True]
{-


True &amp;&amp; (foldr (&amp;&amp;) True [False,False,False,True] )
foldr (&amp;&amp;) True [False,False,False,True]

False &amp;&amp; (foldr (&amp;&amp;) True [False,False,True])
False 


foldr op acc x:xs = x 0111p00…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs11&amp;rev=1682508460&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-04-26T14:27:40+03:00</dc:date>
        <title>pp:2023:haskell:curs11</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs11&amp;rev=1682508460&amp;do=diff</link>
        <description>C11. Programare dinamica lenesa


import Data.Array

t0 :: [Int]
t0 = [2,3,5,1,4]
t1 :: [Int]
t1 = [2,3,5,1,4,6,7,1,2,3,5,3,4,7,1,2,3,4,5,6,7,5,3,4,5,6,7,6,3,2]
t3 :: [Int]
t3 = [2,3,5,1,4,6,7,1,2,3,5,3,4,7,1,2,3,4,5,6,7,5,3,4,5,6,7,6,3,2,2,3,5,1,4,6,7,1,2,3,5,3,4,7,1,2,3,4,5,6,7,5,3,4,5,6,7,6,3,2,2,3,5,1,4,6,7,1,2,3,5,3,4,7,1,2,3,4,5,6,7,5,3,4,5,6,7,6,3,2,2,3,5,1,4,6,7,1,2,3,5,3,4,7,1,2,3,4,5,6,7,5,3,4,5,6,7,6,3,2]
t2 :: [Int]
t2 = [2,3,5,1,4,6,7,1,2,3,5,3,4,7,1,2,3,4,5,6]

-- the operation (!!…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs12&amp;rev=1683113045&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-03T14:24:05+03:00</dc:date>
        <title>pp:2023:haskell:curs12</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs12&amp;rev=1683113045&amp;do=diff</link>
        <description>Curs 12. Typeclasses


-- import Prelude hiding (show, Show)
-- import qualified Prelude as Prelude 

{-
Part 1: Algebraic/Abstract datatypes
-}

data Nat = Zero | Succ Nat -- deriving Show

add :: Nat -&gt; Nat -&gt; Nat
add Zero x = x
add (Succ y) x = Succ (add y x)

toInt :: Nat -&gt; Int
toInt Zero = 0
toInt (Succ x) = 1 + toInt x

{-
    3 + 1 
    3 + 2 + 1

-}
data Expr = Atom Int | Mult Expr Expr | Plus Expr Expr 

type Age = Int

data Student = 
  Student Int (String, String) Int |
  Absolvent I…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs13&amp;rev=1684844434&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-23T15:20:34+03:00</dc:date>
        <title>pp:2023:haskell:curs13</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs13&amp;rev=1684844434&amp;do=diff</link>
        <description>Curs 13. Monade


data Nat = Zero | Succ Nat deriving Show

fromInt :: Int -&gt; Maybe Nat
fromInt x 
  | x &lt; 0 = Nothing
  | otherwise = Just (get x)
   where get 0 = Zero
         get x = Succ (get (x-1))

{-
minus :: Maybe Nat -&gt; Maybe Nat -&gt; Maybe Nat
minus (Just x) (Just y) = 
  case (x,y) of
    (Zero,Zero) -&gt; Just Zero
    (Zero,_) -&gt; Nothing
    (Succ n, Succ m) -&gt; minus (Just n) (Just m)
minus _ _ = Nothing
-}

--increment :: Maybe Nat -&gt; Maybe Nat
--larger3 :: Maybe Nat -&gt; Maybe Bool
--e0…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs14&amp;rev=1684844483&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-23T15:21:23+03:00</dc:date>
        <title>pp:2023:haskell:curs14</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:curs14&amp;rev=1684844483&amp;do=diff</link>
        <description>Curs 14. The Parser Monad


import Data.Char
import Control.Applicative

data Expr = Atom Int | 
            Var String | 
            Plus Expr Expr deriving Show


--type Parser a = String -&gt; [(a,String)]
-- Parser :: * =&gt; *
data Parser a = Parser (String -&gt; [(a,String)])

parse :: Parser a -&gt; String -&gt; [(a,String)]
parse (Parser p) s = p s 

--parseAtom :: Parser Expr
--parse parseAtom &quot;1 + 2&quot; = [(1, &quot;+ 2&quot;)]

{- parsere mai generale: -}
failParser :: Parser a
failParser = Parser $ \s -&gt; []

c…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l07-extra&amp;rev=1712676774&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-04-09T18:32:54+03:00</dc:date>
        <title>pp:2023:haskell:l07-extra</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l07-extra&amp;rev=1712676774&amp;do=diff</link>
        <description>Lambda Calculus as a programming language

Church Encodings

Booleans

We can encode boolean values TRUE and FALSE in lambda calculus as functions that take 2 values, x and y, and return the first (for TRUE) or second (for FALSE) value. 


$ TRUE = \lambda x.\lambda y.y$ 

$ FALSE = \lambda x.\lambda y.x$ 

TRUE$ AND = \lambda x.\lambda y.((x \ y) \ x) $$ OR = \lambda x.\lambda y.((x \ x) \ y) $$ NOT = \lambda x.((x \ FALSE) \ TRUE) $$ NOT = \lambda x.\lambda a.\lambda b.((x \ b) \ a) $$ NOT \ T…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l07&amp;rev=1682547445&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-04-27T01:17:25+03:00</dc:date>
        <title>pp:2023:haskell:l07</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l07&amp;rev=1682547445&amp;do=diff</link>
        <description>Lab 7. Lambda Calculus. Intro to Haskell

7.1 Lambda Calculus

Lambda Calculus represent a axiomatic system that can be used for very basic proofs. 

Given a set of variables VARS, a expression under lambda calculus can be: 

  variable      $ x $           $ x \in VARS $$ \lambda x.e $$ x \in VARS $$ e $$ \lambda $$ (e_1 \ e_2) $$ e_1, e_2 $$ \lambda $$\lambda$$ \lambda x.e $$ \lambda x.body \ param$$ body[x \ / \ param] $$ E_1 = \lambda x.e_1 \ e_2 $$ E_2 = e_1[x \ / \ e_2] $$ \beta $$ E_1 $$ …</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l08&amp;rev=1682693033&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-04-28T17:43:53+03:00</dc:date>
        <title>pp:2023:haskell:l08</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l08&amp;rev=1682693033&amp;do=diff</link>
        <description>8. Lazy Evaluation

When passing parameters to a function, programming language design offers two options which are not mutually exclusive (both strategies can be implemented in the language):

	*  applicative (also called strict) evaluation strategy:$ 2$$ parent + 1$$ parent * 2$$ \lvert s_n - s_{n+1} \rvert &lt; e$$ \displaystyle \lim_{n \rightarrow \infty} \frac{F_{n+1}}{F_n} = \varphi$$ F_n$$ \varphi$$ a_{n+1} = a_n + sin(a_n)$$ a_0$$ a_{n+1} != a_n$$ \displaystyle \lim_{n \rightarrow \infty} a…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l08_2&amp;rev=1682594162&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-04-27T14:16:02+03:00</dc:date>
        <title>pp:2023:haskell:l08_2</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l08_2&amp;rev=1682594162&amp;do=diff</link>
        <description>8. Lazy Evaluation

When passing parameters to a function, programming language design offers two options which are not mutually exclusive (both strategies can be implemented in the language):

	*  applicative (also called strict) evaluation strategy:$ 2$$ parent + 1$$ parent * 2$$ \lvert s_n - s_{n+1} \rvert &lt; e$$ \displaystyle \lim_{n \rightarrow \infty} \frac{F_{n+1}}{F_n} = \varphi$$ F_n$$ \varphi$$ a_{n+1} = a_n + sin(a_n)$$ a_0$$ a_{n+1} != a_n$$ \displaystyle \lim_{n \rightarrow \infty} a…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l09&amp;rev=1683054956&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-02T22:15:56+03:00</dc:date>
        <title>pp:2023:haskell:l09</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l09&amp;rev=1683054956&amp;do=diff</link>
        <description>Lab 9. Algebraic Data Types

9.0. Some theory

Types are an essential component in haskell. They start with capital letters, like Int. We have multiple ways of customizing data types. 



The first one is type aliases, signaled by the keyword type. These allow us to rename complex types to simpler types. They are used for better clarity.</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l10&amp;rev=1684167312&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-15T19:15:12+03:00</dc:date>
        <title>pp:2023:haskell:l10</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=pp:2023:haskell:l10&amp;rev=1684167312&amp;do=diff</link>
        <description>Lab 10. Monads

10.0. Understanding Monads

A monad is an algebraic structure used to describe computations as sequences of steps, and to handle side effects such as state and IO. They also provide a clean way to structure our programs. 



In Haskell, Monads are defined as follows:</description>
    </item>
</rdf:RDF>
