No title

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
type Gen a = Seed -> (a, Seed)

generalA :: (a -> b) -> Gen a -> Gen b
generalA f g = applyOnVal f . g

generalB :: (a -> b -> c) -> Gen a -> Gen b -> Gen c
generalB x g1 g2 s = (x v1 v2, s2) 
  where 
    (v1, s1) = g1 s
    (v2, s2) = g2 s1

genTwo :: Gen a -> (a -> Gen b) -> Gen b
genTwo gen f = uncurry f . gen

applyOnSeed :: Gen b -> (a, Seed) -> (a, (b, Seed))
applyOnSeed f (x, y) = (x, f y)

applyOnVal :: (a -> b) -> (a, Seed) -> (b, Seed)
applyOnVal f (x, y) = (f x, y)