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

Pages: 1-

"Haskell is referentially transparent"

Name: Anonymous 2015-06-13 11:30

This means that functions really are mathematical functions, not horrible complex imperative procedures. So if x == y then f x == f y too. This allows us to use equational reasoning and math and the entirety of category theory as a resource to draw upon when programming

but thats wrong..

Prelude> let d x = 2*x :: Int
Prelude> minBound == maxBound
True
Prelude> d minBound == d maxBound
False

Name: Mentifex 2015-06-13 12:01

Name: Anonymous 2015-06-13 14:16

Strange. I wonder why minBound and maxBound are in Eq.

Name: Anonymous 2015-06-14 19:45

That's because Int is bounded, you mongoloid.

Name: Anonymous 2015-06-14 19:48

>>1
What the fuck are you doing you donkey?
λ> (minBound :: Int) == (maxBound :: Int)
False
λ> d minBound == d maxBound
False

Name: Anonymous 2015-06-14 22:31

>>5
He's been bitten by the monomorphism restriction (Bounded a => a defaulted to () in ghci).

Doesn't happen outside of ghci:
$ cat anus.hs
val = minBound == maxBound

main = print val
$ runghc anus.hs

anus.hs:1:7:
No instance for (Bounded a0) arising from a use of ‘minBound’
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance Bounded () -- Defined in ‘GHC.Enum’
instance (Bounded a, Bounded b) => Bounded (a, b)
-- Defined in ‘GHC.Enum’
instance (Bounded a, Bounded b, Bounded c) => Bounded (a, b, c)
-- Defined in ‘GHC.Enum’
...plus 17 others
In the first argument of ‘(==)’, namely ‘minBound’
In the expression: minBound == maxBound
In an equation for ‘val’: val = minBound == maxBound

anus.hs:1:16:
No instance for (Eq a0) arising from a use of ‘==’
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance Eq a => Eq (GHC.Real.Ratio a) -- Defined in ‘GHC.Real’
instance Eq () -- Defined in ‘GHC.Classes’
instance (Eq a, Eq b) => Eq (a, b) -- Defined in ‘GHC.Classes’
...plus 23 others
In the expression: minBound == maxBound
In an equation for ‘val’: val = minBound == maxBound
$

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