‘perf’ have two arguments, but its type ‘[Qops a] -> [a]’ has only one

Viewed 76

Couldn't match expected type ‘[a]’ with actual type ‘p0 -> p0’ • The equation(s) for ‘perf’ have two arguments, but its type ‘[Qops a] -> [a]’ has only one • Relevant bindings include perf :: [Qops a] -> [a] (bound at lab3.hs:16:1)

lab3.hs:17:17: error: • Couldn't match expected type ‘t0 -> p0’ with actual type ‘[a]’ • The function ‘perf’ is applied to two arguments, but its type ‘[Qops a] -> [a]’ has only one In the expression: perf xs (perfOne x q) In an equation for ‘perf’: perf (x : xs) q = perf xs (perfOne x q) • Relevant bindings include q :: p0 (bound at lab3.hs:17:13) xs :: [Qops a] (bound at lab3.hs:17:9) x :: Qops a (bound at lab3.hs:17:7) perf :: [Qops a] -> [a] (bound at lab3.hs:16:1)

import Data.List (sort)
import Queue1
--import Queue2
import Fraction

---------------- Part 1: Queue client

-- Queue operations (A = add, R = remove)
data Qops a = A a | R

-- Perform a list of queue operations on an emtpy queue,
-- returning the list of the removed elements
perf :: [Qops a] -> [a]
perf [] q = q 
perf (x:xs) q = perf xs (perfOne x q)

perfOne (A x) q = error "Queue: add"
perfOne R q = error "Queue: remove"

-- Test the above functions thouroughly. For example, here is one test:
-- perf [A 3, A 5, R, A 7, R, A 9, A 11, R, R, R] ---> [3,5,7,9,11]

For my empty perf I am getting an error perf’ have two arguments,
      but its type ‘[Qops a] -> [a]’ has only one
can someone help me or explain how i can fix this 
0 Answers
Related