Created
June 18, 2015 11:08
-
-
Save dzackgarza/47740e1d710377938afa to your computer and use it in GitHub Desktop.
Trying to move a do block within a case assignment
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
someMaybe :: UserID | |
someVariable :: Html | |
simpleRenderFunction :: (Int -> String) -> Html | |
-- For example, string is a user name: is this a known user? | |
testCondition :: MonadIO m => String -> m Bool | |
-- Takes into account the result from the testCondition function. | |
complicatedRenderFunction :: (Int -> String -> Bool) -> Html | |
complicatedRenderFunction a s b = case b of .... | |
------ The way it was done before: | |
isThisAUser <- testCondition "User1" | |
let someVariable = complicatedRenderFunction 200 "Hello" isThisAUser | |
--------- | |
----- Attempted refactor | |
let someVariable = case someMaybe of | |
Nothing -> | |
simpleRenderFunction 200 "Hello" | |
Just someValue -> | |
-- evaluate the test condition and use it in the assignment? | |
testCondition "User1" >>= complicatedRenderFunction 200 "Hello" | |
-- Evaluates to a bool -- Partially applied, only bool argument needs to be filled? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment