Last active
December 26, 2019 11:18
-
-
Save happy-bracket/abe8a51fae4784717ac808f9c97870c4 to your computer and use it in GitHub Desktop.
Revisions
-
happy-bracket revised this gist
Dec 26, 2019 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ -- TEA with transactional-like mutations type Upd s m e = s -> m -> (s, [e]) data TMutation s e = TMutation { state :: s -> s, effs :: s -> [e] } type TUpd s e = Upd s (TMutation s e) e -
happy-bracket created this gist
Dec 26, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ {-# LANGUAGE GADTs #-} module Main where newtype Login = Login String newtype Password = Password String data LoginState = Auth { login :: Login, password :: Password } | Nop data LoginMutation where Input :: Either Login Password -> LoginMutation LoginClicked :: LoginMutation data LoginEffect where TryLogin :: Login -> Password -> LoginEffect update :: LoginState -> LoginMutation -> (LoginState, [LoginEffect]) update s (Input (Left l)) = (s { login = l }, []) update s (Input (Right p)) = (s { password = p }, []) update s LoginClicked = (s, [TryLogin (login s) (password s)])