[Haskell-cafe] Overcome type restrictions?

Kolář Dušan kolar at fit.vutbr.cz
Fri Mar 7 06:57:09 UTC 2014


Hello Café,

   Is there any way to overcome this other way then by introducing  
some helper data types etc. etc.?

We have:

Prelude> :t ([head, last, head, last, head, last])
([head, last, head, last, head, last]) :: [[a] -> a]

Prelude> :t (\(h:t) -> head t)
(\(h:t) -> head t) :: [a] -> a

Prelude> :t ((\(h:t) -> head t) [head, last, head, last, head, last])
((\(h:t) -> head t) [head, last, head, last, head, last])
   :: [a] -> a

But we have an error of infinite type construction for

Prelude> :t ((\(h:t) -> h t) [head,tail, head, tail, head, tail])

Well I can overcome this by encoding functions into data types and  
then performing "conversion" back and forth, nevertheless, is there  
any way how to overcome this?

My real problem is not about head/tail, but head/tail is the simplest  
way how to explain.

Thanks for any references,

Dušan




More information about the Haskell-Cafe mailing list