1

Hello is there any way to solve this recurrent problem of incorrect indentation in Haskell ? I am using VSCode and many times i just have to put an extra space to be able to compile the module.Is there any way (extension) which can show me how to manage tabs/spaces...etc ?

module DB where
        import Company
        let db= [
                Company{
                    compName="Siemens",
                    year=1912,
                    employees=[
                        Employee{age=25,name="Stew",job=Worker},
                        Employee{age=25,name="Michael",job=Manager,wage=66},
                        Employee{age=22,name="Stew",job=Worker,wage=33.0},
                        Employee{age=32,name="Dew",job=Unemployed,wage=0.5},
                        Employee{age=44,name="Drey",job=Worker,wage=30.0}]
                },
                Company{
                    compName="ABB",
                    year=1925,
                    employees=[
                        Employee{age=18,name="Michael",job=Manager,wage=21},
                        Employee{age=23,name="Rey",job=Worker,wage=18.5},
                        Employee{age=55,name="Barry",job=Unemployed,wage=0.7},
                        Employee{age=64,name="Dean",job=Worker,wage=30.0}]
                },
                Company{
                     compName="EATON",
                     year=1977,
                     employees=[
                        Employee{age=18,name="Raynald",job=Manager,wage=21},
                        Employee{age=23,name="Fitz",job=Worker,wage=18.5},
                        Employee{age=55,name="Alex",job=Worker,wage=0.7},
                        Employee{age=34,name="Bob",job=Worker,wage=23.0},
                        Employee{age=33,name="Odo",job=Unemployed,wage=24.0}]
                      }
             ]
3
  • 3
    1. Never use tabs, ever. 2. Use indentation to group stuff together that belongs together. 3. Don't indent top-level stuff like import and global definitions. (Also don't use let for these, that's only needed for local definitions.) Commented Aug 10, 2018 at 11:29
  • 2
    Modern GHC should already warn about tabs. You should avoid them, or be quite disciplined in how tabs are used. Also note that indentation matters only after let, do, where, case of. Inside [ ] there are no rules. Ensure the last ] above is indented more than the db after let. (And let is also wrong there...)
    – chi
    Commented Aug 10, 2018 at 12:03
  • Oh it was actually because let.I thought you can use it ouside a method.I am sorry for the goose hunt.It can be closed ! Commented Aug 10, 2018 at 12:30

1 Answer 1

1

The problem was using the let keyword outside a method.

Not the answer you're looking for? Browse other questions tagged or ask your own question.