Похожие чаты

Language: Haskell Source: Rpn [] f = f rpn [h:t] f = rpn t

(f h)

main = print $ rpn [2, 3] (+)

Errors:
source_file.hs:2:19:
Occurs check: cannot construct the infinite type: t ~ [t]
Expected type: [[t]]
Actual type: [t]
Relevant bindings include
f :: t -> t1
(bound at source_file.hs:2:11)
t :: [t]
(bound at source_file.hs:2:8)
h :: t (bound at source_file.hs:2:6)
rpn :: [[t]] -> (t -> t1) -> t -> t1
(bound at source_file.hs:1:1)
In the first argument of ‘rpn’, namely ‘t’
In the expression: rpn t (f h)

source_file.hs:2:22:
Occurs check: cannot construct the infinite type: t1 ~ t -> t1
Relevant bindings include
f :: t -> t1
(bound at source_file.hs:2:11)
t :: [t]
(bound at source_file.hs:2:8)
h :: t (bound at source_file.hs:2:6)
rpn :: [[t]] -> (t -> t1) -> t -> t1
(bound at source_file.hs:1:1)
In the second argument of ‘rpn’, namely ‘(f h)’
In the expression: rpn t (f h)

source_file.hs:4:8:
No instance for (Show (a0 -> a0 -> a0))
(maybe you haven't applied enough arguments to a function?)
arising from a use of ‘print’
In the expression: print
In the expression: print $ rpn [2, 3] (+)
In an equation for ‘main’: main = print $ rpn [2, 3] (+)

source_file.hs:4:21:
No instance for (Num [a0]) arising from the literal ‘2’
In the expression: 2
In the first argument of ‘rpn’, namely ‘[2, 3]’
In the second argument of ‘($)’, namely ‘rpn [2, 3] (+)’

source_file.hs:4:27:
No instance for (Num a0) arising from a use of ‘+’
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance Num Integer -- Defined in ‘GHC.Num’
instance Num Double -- Defined in ‘GHC.Float’
instance Num Float -- Defined in ‘GHC.Float’
...plus two others
In the second argument of ‘rpn’, namely ‘(+)’
In the second argument of ‘($)’, namely ‘rpn [2, 3] (+)’
In the expression: print $ rpn [2, 3] (+)

5 ответов

5 просмотров

It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.

Wojciech-Pawlik Автор вопроса

what have I done

I suppose [] is the argument list?

And t is the tails function?

Oh.. Your Base case is wrong.. If I can guess the haskell syntax, rpn [] f = [] rpn [h:t] f = (rpn t f) h f

Похожие вопросы

Обсуждают сегодня

I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
1
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
Почему у макбука экран не сенсорный?
✨ Anatolii Cherednichenko
28
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
а как ловят такое ghci> res <- getPos2 urlt 0 (alist !! 0) 200 ghci> res SearchAtom (Search "www.google.com" "/search?q=" "Haskell") "haskell.org" (SearchTS [(2024-05-06 07:...
Fedor
14
Is it a good price to buy hex now on 0,0019?
Patrick
29
короче сгенерила мне эта штука код на ассемблере: struc string val { common local .value dq .value .value: if ~val eq db val end if db 0 } fo...
Vi Chapmann Chapmann
12
Есть тут те у кого дети есть + 2 работы + в зал ходят + в семейной жизни все хорошо?
Abdul-Aziz M.
13
Я пожалуй ещё раз брошу клич: кто-нибудь хочет в рабство в ОЭЗ Алабугу на позицию инженера CV? Работы много, задачи сложные, ЗП высокая. Я передам контакт напрямую в HR.
Maxim 👀 Osminin #Slowpoke3D
13
Всем привет! Массив вводится с клавиатуры, кол-во элементов неизвестно, поэтому я указал arr db 100 dup(?) С нахождением максимума проблем нет, а вот минимум почему-то всегд...
En Vind Av Sorg
11
Карта сайта