[Haskell-beginners] indentation

Jorden Mauro jrm8005 at gmail.com
Sun Feb 14 16:30:27 EST 2010


On Sun, Feb 14, 2010 at 3:20 PM, Daniel Fischer
<daniel.is.fischer at web.de> wrote:
> Am Sonntag 14 Februar 2010 20:54:54 schrieb John Moore:
>> Hi all,
>>          I must be doing something wrong with my tabs. Because this
>> keeps telling me parse error. Can some one see if it is indentation. I'm
>> sending a file so as you'll be able to see what going on. If I copy it
>> here it can appear wrong the difference is with the Var expression.
>>
>> John
>
> First of all, *don't mix tabs and spaces for indentation* (best, don't use
> tabs at all).

I find the latter a bit too restrictive, especially since I use a text
editor that is a glorified version of ed. Hitting the spacebar 19
times is too much to ask of me.

And as such, I am occasionally forced to do something when a tab
doesn't get me past the word `where' or `let', but isn't that the
majority of what Layout specifies?

Is there a good answer for caveman programmers who like ed and tabs?

>
> It's
>
> evalStep d (Var x)
>     = case x of
>        (Val a) ->case x of
>          (Val b) ->(lookup x d)
>          if (isJust m_e)then
>           evalStep(lookup x d)
>           else
>            fail "Error in expression -- no definition for variable!"
>
> The "if ... " is aligned with (Val b), so GHC tries to parse it as a
> pattern. But if-expressions aren't patterns, so you get a parse error.
>
> But the code doesn't really make sense (and isn't well typed) anyway.
> You probably want something like
>
> evalStep d (Var x)
>    = case lookup x d of
>        Just e -> e
>        Nothing -> error "Error in expression -- no definition for
> variable!"
>
> for that.
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>


More information about the Beginners mailing list