Re: [Haskell-cafe] indentation with let and do

2013-10-03 Thread David McBride
Imagine if bar was a toplevel function bar = case foo of True - Foo; False - Bar; Keep in mind that indentation level starts at the function name, not at the let keyword. On Thu, Oct 3, 2013 at 2:31 PM, Corentin Dupont corentin.dup...@gmail.comwrote: Hi the list, why do this function

Re: [Haskell-cafe] Importing more modules by default

2013-08-08 Thread David McBride
I've started using BasicPrelude with -XNoImplicitPrelude in all of my code. It imports all of those and some other stuff as well (text related functions). Cuts down on my imports by a little over half. Kind of wish it could be made the default. On Wed, Aug 7, 2013 at 10:23 PM, aditya bhargava

Re: [Haskell-cafe] How can I use ghci more wisely?

2013-07-24 Thread David McBride
You might like to know about this option for ghci -interactive-print I tested it with data-pprint though and it didn't work because it returns an IO Doc instead of IO () (I assume). But if you wrote a function that used that, returned the right type, cabal installed it and put it in your .ghci,

Re: [Haskell-cafe] Parsec error message not making any sense

2013-07-10 Thread David McBride
First, I want to say you'd have a lot better luck with these questions by posting to stackoverflow. This really isn't the right place for it. As for why your parser is not working, you need to realize that parsec does not backtrack by default. It does this to conserve memory (so it doesn't have

Re: [Haskell-cafe] Basic Parsec float integer parsing question

2013-07-05 Thread David McBride
Token parsers are specific to different languages. Afterall, haskell parses floats differently than C, which is different from java (probably). In order to use it in your code you have to tell it that, like so: haskelldef = makeTokenParser haskellDef header :: Parser LabelFile header = do

Re: [Haskell-cafe] same function's type accepted in top level, but rejected in where clause

2013-07-05 Thread David McBride
If you remove the type signature from f in the where clause it will work. The reason is because the type signature listed there, the a is a different a than in the top level signature. If you change it from a to x, it says it should be the a that you can't seem to specify. If you add the pragma

Re: [Haskell-cafe] Casting newtype to base type?

2013-07-02 Thread David McBride
You could always just put it into your newtype: newtype IOS = IOS { unIOS :: IO String } On Tue, Jul 2, 2013 at 9:31 AM, Vlatko Basic vlatko.ba...@gmail.com wrote: Original Message Subject: Re: [Haskell-cafe] Casting newtype to base type? From: Tom Ellis

Re: [Haskell-cafe] (+) on two lists ?

2013-02-14 Thread David McBride
sum' [] = [] -- returns a list of something the way you intended sum' (x:xs) = x + xum' xs -- you intended it not to return a list but it could if you think about it. The compiler says I think returns a list based on what I see so far, well if you can add these together then the only way you

Re: [Haskell-cafe] Teaching Haskell @ MOOCs like Coursera or Udacity

2012-10-24 Thread David McBride
I'm taking it primarily because it is taught by the guy who made the language. I mean how cool is that? He is very smart and certainly blows any other lecturer I've ever had out of the water. If SPJ were doing a haskell course I'd sign up for that too in a heart beat. There's also a slim

Re: [Haskell-cafe] Yesod a href render issue

2012-08-31 Thread David McBride
Hamlet is whitespace sensitive like haskell and python. If you put a tag after text, it is treated as text. Write the a... on the next line and it will work. On Fri, Aug 31, 2012 at 7:14 PM, Thiago Negri evoh...@gmail.com wrote: I'm following Yesod tutorial that gives this as the first

Re: [Haskell-cafe] hGetContents Illegal byte sequence / ghc-pkg

2012-08-11 Thread David McBride
I had this same problem a couple weeks ago when trying to install virthualenv and I don't really understand it got into a bad state, but the way I solved it was by fixing the locale settings on my gentoo machine so that I'm using UTF8. That just involved a few changes in /etc and then the problem

Re: [Haskell-cafe] IO() and other datatypes

2012-03-04 Thread David McBride
Just use this rule of thumb. If it is a monad (like IO Int, IO String) use do - notation. If it isn't a monad (like Int, String), just use let syntax, same as you did with the first list. main = do let ttime = [8,20,10,15] a = dauer ttime (OPTIONAL let a = dauer ttime) putStrLn a On

Re: [Haskell-cafe] Will changing associativity of enumerator's ($=) affect anyone? (also: enumerator mailing list)

2011-10-15 Thread David McBride
This would be a big boon to newbies. When I first started using the library I would get big errors using $= that were because I didn't have parenthesis I needed, but didn't realize I needed, despite the fact that the types seemed to line up. On Sat, Oct 15, 2011 at 12:40 PM, Michael Snoyman

Re: [Haskell-cafe] Binding of an integer variable

2011-07-28 Thread David McBride
It hasn't been evaluated yet. It is just a thunk. let x = 23 :show bindings x :: Integer = _ x 23 :show bindings x :: Integer = 23 On Thu, Jul 28, 2011 at 2:43 PM, Paul Reiners paul.rein...@gmail.com wrote: I have a question about the following GHCi interaction: Prelude let x = 23 Prelude

Re: [Haskell-cafe] file splitter with enumerator package

2011-07-25 Thread David McBride
blah = do fp - openFile file ReadMode run_ $ (ET.enumHandle fp $= ET.lines) $$ printChunks True printChunks is super duper simple: printChunks printEmpty = continue loop where loop (Chunks xs) = do let hide = null xs not printEmpty CM.unless hide

Re: [Haskell-cafe] file splitter with enumerator package

2011-07-25 Thread David McBride
, and not just random blocks. Isn't there a primitive like printChunks in the enumerator library, or are we forced to handle Chunks and EOF by hand? 2011/7/25 David McBride dmcbr...@neondsl.com blah = do  fp - openFile file ReadMode  run_ $ (ET.enumHandle fp $= ET.lines) $$ printChunks True

Re: [Haskell-cafe] file splitter with enumerator package

2011-07-25 Thread David McBride
experience I don't want it to stop there if there are more idiomatic ways to write code with the enumerator package. On Mon, Jul 25, 2011 at 4:06 AM, David McBride dmcbr...@neondsl.com wrote: Well I was going to say: import Data.Text.IO as T import Data.Enumerator.List as EL import

[Haskell-cafe] Vi mode in ghci?

2011-06-10 Thread David McBride
Somehow in the distant past I managed to get vi editing mode working for ghci on ghc 6, but when I upgraded to ghc 7, I can't seem to figure out how to enable it anymore. I think I might have been using ghci-haskeline in the past. A post I read somewhere suggested that ghc 7 should have innate

Re: [Haskell-cafe] Vi mode in ghci?

2011-06-10 Thread David McBride
I do remember reading this page way back when. Thank you very much! On Fri, Jun 10, 2011 at 4:41 PM, Evan Laforge qdun...@gmail.com wrote: On Fri, Jun 10, 2011 at 1:25 PM, David McBride dmcbr...@neondsl.com wrote: Somehow in the distant past I managed to get vi editing mode working for ghci

Re: [Haskell-cafe] Regex multiple matches

2010-07-20 Thread David McBride
It is even simpler than that. The type determines the return value. axxfayyf =~ a..f :: Bool True axxfayyf =~ a..f :: Int 2 axxfayyf =~ a..f :: String axxf axxfayyf =~ a..f :: [[String]] [[axxf],[ayyf]] axxfayyf =~ a..f :: [MatchArray] [array (0,0) [(0,(0,4))],array (0,0) [(0,(4,4))]]

Re: [Haskell-cafe] Regex multiple matches

2010-07-20 Thread David McBride
Nevermind I see that you already knew that. But it is very cool anyways, I'm totally going to use regexes more often now that I've discovered it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Advice for clean code.

2007-12-03 Thread David McBride
I am still in the early stages learning haskell, which is my first foray into functional programming. Well there's no better way to learn than to write something, so I started writing a game. Mostly the thing looks good so far, far better than the C version did. However, my problem is that