This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fp09 where | |
import Control.Applicative (Alternative(..),optional,ZipList(..)) | |
import Data.Char (isLower,isUpper,digitToInt,isDigit) | |
import Data.Monoid (Alt(..),Ap(..),Sum(..)) | |
import Data.Functor.Identity (Identity(..)) | |
newtype Parser tok a = | |
Parser { runParser :: [tok] -> Maybe ([tok],a) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE Rank2Types #-} | |
module Fp15SimpleLens where | |
{- | |
Линза - инструмент для манипулирования элементом типа a некоторой структуры данных типа s, | |
находящимся в фокусе этой линзы. | |
Технически линза - это АТД составленный из пары геттер-сеттер | |
lens :: (s -> a) -> (s -> a -> s) -> Lens s a | |
Законы: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
module LamInhab where | |
import Data.List (insertBy) | |
import Control.Monad.State | |
-- Тип символов | |
type Symb = String | |
infixl 2 :@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Определим на Агде интуиционистскую логику высказываний | |
-} | |
module PropCalculusMini where | |
{- | |
Задаём стандартные приоритеты и ассоциативность | |
для логических связок | |
-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FilterEtAl where | |
data Bool : Set where | |
false : Bool | |
true : Bool | |
data ℕ : Set where | |
zero : ℕ | |
suc : (n : ℕ) → ℕ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Законы аппликативных функторов выполняются для | |
-- стандартного представителя (Either e) | |
instance Applicative (Either e) where | |
pure = Right | |
Left e <*> _ = Left e | |
Right f <*> r = fmap f r | |
instance Functor (Either a) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -XStandaloneDeriving #-} | |
module Fp06 where | |
-- Производные представители (Derived Instances) | |
data Point a = Point a a deriving Eq | |
-- (Pt 3 5) == (Pt 3 5) | |
-- В GHC можно и отдельно (с ключом -XStandaloneDeriving) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fp05 where | |
-- переставляет элементы пары местами (определена в Data.Tuple) | |
swap :: (a,b) -> (b,a) | |
swap (x,y) = (y,x) | |
-- перечисление | |
data Color = Red | Green | Blue | Indigo | Violet deriving Show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fp04 where | |
x = 2 -- глобальное | |
y = 42 -- глобальное | |
foo = let z = x + y -- глобальное (foo) локальное (z) | |
in print z -- отступ (layout rule) | |
add x y = x + y -- определение add | |
add' x = \y -> x + y | |
add'' = \x y -> x + y |