Skip to content

Error in code snippet - Chapter Single Digit Math #5

@shubhamkumar13

Description

@shubhamkumar13

function created to compute expression :
expression (x:y:z:[]) = (term x) ++ (addOperation y) ++ (term z)

shows a type error

    • Couldn't match expected type ‘[Char]’ with actual type ‘Char’
    • In the second argument of ‘(++)’, namely ‘(term z)’
      In the second argument of ‘(++)’, namely
        ‘(addOperation y) ++ (term z)’
      In the expression: (term x) ++ (addOperation y) ++ (term z)
   |
17 | expression (x:y:z:[]) = (term x) ++ (addOperation y) ++ (term z)
   |                                                          ^^^^^^

Possible but immature(imo) solution(or hack) that I came up with is
expression (x:y:z:[]) = (term x : []) ++ (addOperation y) ++ (term z : [])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions