CARVIEW |
Select Language
HTTP/2 200
date: Mon, 13 Oct 2025 14:33:04 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=09d62ea00ef7ecbd041a7a2438db961a6807e4f074566ea34d6561342e3b8359a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22UCeLaQtWaoQD8ED_Bau0OSiJo1cd8OSt%22%3B%7D; HttpOnly; Path=/
cf-ray: 98df8cc7b85de084-BLR
Haskell ArrowReader & ArrowState - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE Arrows #-}
- {-# LANGUAGE FlexibleInstances #-}
- {-# LANGUAGE FunctionalDependencies #-}
- module Arr where
- {-
- As an exercise in learning arrows, I implemented a reader arrow called EA
- and a state arrow called S.
- -}
- import Prelude hiding ((.), id)
- import Control.Category
- import Control.Arrow
- import qualified Data.Bifunctor as BiF
- newtype EA r a b = EA { runEA :: r -> a -> b }
- instance Arrow (EA r) where
- arr f = EA $ const f
- first (EA f) = EA $ BiF.first . f
- second (EA f) = EA $ BiF.second . f
- instance Category (EA r) where
- id = arr id
- (EA b) . (EA a) = EA $ \r -> b r . a r
- class Arrow a => ArrowReader r a | a -> r where
- ask :: a () r
- instance ArrowReader r (EA r) where
- ask = EA const
- newtype S s a b = S { runS :: s -> a -> (b, s) }
- evalS :: S s a b -> s -> a -> b
- evalS z s a = fst $ runS z s a
- execS :: S s a b -> s -> a -> s
- execS z s a = snd $ runS z s a
- instance Arrow (S s) where
- arr f = S $ \s a -> (f a, s)
- first (S f) = S $ \s (a, b) -> let (a', s') = f s a in ((a', b), s')
- second (S f) = S $ \s (a, b) -> let (b', s') = f s b in ((a, b'), s')
- instance Category (S s) where
- id = arr id
- (S b) . (S a) = S $ \s x -> let (a', s') = a s x in b s' a'
- class Arrow a => ArrowState s a | a -> s where
- get :: a b s
- put :: a s ()
- modify :: ArrowState s a => a (s -> s) ()
- modify = proc f -> do
- s <- get -< ()
- put -< f s
- instance ArrowState s (S s) where
- get = S $ \s _ -> (s, s)
- put = S $ \_ s -> ((), s)
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ H
JavaScript | 5 sec ago | 0.25 KB
-
⭐⭐⭐Profit Method⭐⭐
Java | 8 sec ago | 0.15 KB
-
📝 EASY MONEY GUIDE ✅ Working R
JavaScript | 14 sec ago | 0.25 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 20 sec ago | 0.15 KB
-
📌 Instant BTC Profit Method ✅ Working E
JavaScript | 23 sec ago | 0.25 KB
-
✅ Make $2500 in 20 minutes⭐ X
JavaScript | 31 sec ago | 0.25 KB
-
⭐⭐⭐Crypto Accounts⭐⭐
Java | 32 sec ago | 0.15 KB
-
✅ Make $2500 in 20 minutes⭐ X
JavaScript | 32 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand