Error in haskell. Please guide me on how to fix this

ray
import Data.List
step :: [Int] -> String -> [Int] 
step (x:y:ys) "*" = (x * y):ys
step (x:y:ys) "+" = (x + y):ys
step (x:y:ys) "-" = (y - x):ys
step xs numberString = read numberString:xs

This my code and error i keep getting is below, please any help is appreciated. Thank you.

*Main> step [2+6]: this is what i put into my terminal

<interactive>:5:1: error:
    • No instance for (Show (String -> [Int]))
        arising from a use of ‘print’
        (maybe you haven't applied a function to enough arguments?)
    • In a stmt of an interactive GHCi command: print it
*Main> 
JonathanArns

With step [2+6] you are only partially applying your function, so the return value is not a list [Int], but a function String -> [Int]. (Partially applying a function means to only provide some of the arguments it needs and getting a function back that takes the rest of the arguments. Yes, you can do this in Haskell!)

The error you see, will only arise in the terminal, because ghci tries to apply show to every statement, but functions are not showable.

So if you want to fully apply your function to see it in action, you need to provide all the arguments it needs, i.e.

step [1, 2, 3] "+"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how i fix this "Syntax error:Unexpected identifier" please help me

Unity error CS0273 please tell me how to fix it

Can anyone please help me to fix this error?

Please help me to fix the error - mysqlclient

How to fix the two button center and right side? im expecting the best answer without using "dp".please guide me

Can someone please guide me on how to reuse a function in a class?

condition is not working please guide me how to get proper data

please guide me to split the image

Please how do I fix this SMTPConnectError Error?

i am having this error(at onBackpressed block) after exiting app should i go with this error or if not please tell me how to fix it

Please tell me how to resolve a type error

Please help me fix this IF statement

error cs0029 how to fix this error please

Please guide me, my program is not working and showing error id return 1 exit status

How to fix this function please?

how to fix this please tell

how to fix Ambiguous occurrence error in Haskell

How to fix indentation? Haskell: parse error on input `|'

Please how can I fix this error in my react app

Please help me fix an error in tidycensus. Error: Your API call has errors

Error : Please fix the version conflict?

Error: Please fix the version conflict

AttributeError: 'str' object has no attribute 'append'. Please help me fix this error

When inserting CSV data into AWS RDS MySQL DB getting errorMessage 1054 "Unknown column in 'field list'. Please let me know how to fix this error

An error occured while installing pod 'CLTypingLabel'. I don't know how to fix it. I have tried many time. Please someone help me

I cannot build my project. I don't know how to fix this. Please help me

VerifyError occurs after applying android5.1.1 Proguard. Please tell me how to fix it

How to activate a cell on Double Click on VBA(Excel)? Please assist me fix the code

please guide me to covert the below code using joins