Skip to content

Instantly share code, notes, and snippets.

@skatenerd
Created March 21, 2018 23:34
Show Gist options
  • Save skatenerd/e2300fe8adaece4e06341b1b946565df to your computer and use it in GitHub Desktop.
Save skatenerd/e2300fe8adaece4e06341b1b946565df to your computer and use it in GitHub Desktop.
expand.hs
simple = do
first <- pop
pop
return first
pop >>= (\first -> (pop >>= (\_ -> return first)))
(State $ \(x:xs) -> (x,xs)) >>= (\first -> (pop >>= (\_ -> return first)))
State $ \s -> let (a, newState) = (\(x:xs) -> (x,xs)) s
(State g) = (\first -> (pop >>= (\_ -> return first))) a
in g newState
State $ \s -> let (a, newState) = (head s, rest s)
(State g) = (\first -> (pop >>= (\_ -> return first))) a
in g newState
State $ \s -> let (a, newState) = (head s, rest s)
(State g) = (pop >>= (\_ -> return a))
in g newState
State $ \s -> let (State g) = (pop >>= (\_ -> return (head s)))
in g (rest s)
State $ \s -> let (State g) = jawn
in g (rest s)
where jawn = (pop >>= (\_ -> return head s))
State $ \s -> let (State g) = jawn
in g (rest s)
where jawn = ((State $ \(x:xs) -> (x,xs)) >>= (\_ -> return head s))
State $ \s -> let (State g) = jawn
in g (rest s)
where jawn = State (\anotherS -> let (a, newState) = (\(x:xs) -> (x,xs)) anotherS
State q = (\_ -> return head s) a
in q (newState))
State $ \s -> let g = jawnInner
in g (rest s)
where jawnInner = \anotherS -> let (a, newState) = (\(x:xs) -> (x,xs)) anotherS
State q = (\_ -> return head s) a
in q (newState)
State $ \s -> let (a, newState) = (\(x:xs) -> (x,xs)) (rest s)
State q = (\_ -> return head s) a
in q (newState)
State $ \s -> let (a, newState) = (head (rest s), rest (rest s))
State q = return head s
in q (newState)
State $ \s -> let State q = State $ \z -> ((head s),z)
in q (rest (rest s))
State $ \s -> (\z -> ((head s),z)) (rest (rest s))
State $ \s -> (head s, rest(rest(s)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment