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
wrote:
> Hi the list,
> why do this function doesn't compile (parse
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
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, y
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
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
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
str
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 wrote:
>
>
> Original Message
> Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
> From: Tom Ellis
> To: haskell-cafe@haskell.org
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 coul
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 possib
Hamlet is whitespace sensitive like haskell and python. If you put a tag
after text, it is treated as text.
Write the wrote:
> I'm following Yesod tutorial that gives this as the first example for
> "type-safe URLs":
>
> | getHomeR = defaultLayout [whamlet|Go to page 1!|]
>
> Worked fine, the
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
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
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 wrot
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 wrote:
> I have a question about the following GHCi interaction:
>
> Prelude> let x = 23
> Prelude> :show bindin
int I've achieved my original goals,
> unusual as they are, but since this has been an interesting learning
> 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
nd 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
>>
>> blah = do
>> fp <- openFile "file" ReadMode
>> run_ $ (E
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
I do remember reading this page way back when. Thank you very much!
On Fri, Jun 10, 2011 at 4:41 PM, Evan Laforge wrote:
> On Fri, Jun 10, 2011 at 1:25 PM, David McBride wrote:
>> Somehow in the distant past I managed to get vi editing mode working
>> for ghci on ghc 6, but whe
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 su
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
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))],a
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 c
22 matches
Mail list logo