Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell lacks Type Inference

Name: Anonymous 2017-11-24 17:14

benis f = (f ['d'], f [1])
lac.hs:23:22: error:
• No instance for (Num Char) arising from the literal ‘1’
• In the expression: 1
In the first argument of ‘f’, namely ‘[1]’
In the expression: f [1]
Failed, modules loaded: none.

and car cdr = car cdr car
or car cdr = car car cdr

lac.hs:14:23: error:
• Occurs check: cannot construct the infinite type:
t ~ t2 -> t -> t1
• In the second argument of ‘car’, namely ‘car’
In the expression: car cdr car
In an equation for ‘Main.and’: Main.and car cdr = car cdr car
• Relevant bindings include
cdr :: t2 (bound at lac.hs:14:9)
car :: t2 -> t -> t1 (bound at lac.hs:14:5)
Main.and :: (t2 -> t -> t1) -> t2 -> t1 (bound at lac.hs:14:1)

lac.hs:17:18: error:
• Occurs check: cannot construct the infinite type:
t ~ t -> t2 -> t1
• In the first argument of ‘car’, namely ‘car’
In the expression: car car cdr
In an equation for ‘Main.or’: Main.or car cdr = car car cdr
• Relevant bindings include
cdr :: t2 (bound at lac.hs:17:8)
car :: t -> t2 -> t1 (bound at lac.hs:17:4)
Main.or :: (t -> t2 -> t1) -> t2 -> t1 (bound at lac.hs:17:1)

In order to make the above work you need to type it explicitly, like
LANGUAGE Rank2Types #-} --for some reason the shitty syntax highlighter bullshit in this site eats the {-#
type CBool = forall a. a -> a -> a
and :: CBool -> CBool -> CBool
or :: CBool -> CBool -> CBool
benis :: (forall a. a -> b) -> (b, b)


You can't even do benis :: (a -> b) -> (b, b) nor benis :: ([a] -> b) -> (b, b) nor anything that does not use a compiler extension. What a great language!

Name: Anonymous 2017-11-25 1:01

Not gonna lie, former Haskell fanboy here. This is fucking hilarious watching Haskell crash and burn. But in all seriousness we can't let Haskell be the new führer of programming languages.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List