Skip to content

Instantly share code, notes, and snippets.

@Cedev
Created April 16, 2017 05:07
Show Gist options
  • Save Cedev/b55e8bba2d6a33f5023385addbf51c3e to your computer and use it in GitHub Desktop.
Save Cedev/b55e8bba2d6a33f5023385addbf51c3e to your computer and use it in GitHub Desktop.
nested dos
main = do
chars <- getLine
let otherchars = do
a <- chars
b <- chars
[a] ++ [b]
putStrLn otherchars
@VictorTaelin
Copy link

VictorTaelin commented Apr 16, 2017

main =
  let chars = #getLine in
  let otherchars = {
    let a = #chars in
    let b = #chars in
    [a] ++ [b]
  }
  putStrLn otherchars

Edit: this is a type error though, chars :: String, but I get what you mean. The {} makes it desugar in the proper block.

@VictorTaelin
Copy link

VictorTaelin commented Apr 16, 2017

Notice it would be much nicer if the let x = y in z syntax was just x = y; z. Also do could be used to avoid {}, I guess. So,

main =
  chars = #getLine
  otherChargs = do
    a = #chars
    b = #chars
    a ++ b
  putStrLn otherChars

In an ideal world?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment