OK, I've figured it out. In this O'Haskell statement,
> struct Derived < Base =
> value :: Int
...Derived is not, in fact, a subtype of Base. Derived and Base are
disjoint types, but an implicit map of type "Derived -> Base" has been
defined.
--
Ashley Yakeley, Seattle WA
Ashley Yakeley wrote:
>
> At 2001-01-16 14:04, Tom Pledger wrote:
>
> >The subtyping (struct Derived < Base ...) makes the two instances
> >overlap, with 'instance TheValue Derived' being strictly more specific
> >than 'instance TheValue Base'. If the system preferred the less
> >specific one,
At 2001-01-16 13:18, Magnus Carlsson wrote:
>f1 = Just 3
>f2 = f3 = f4 = Nothing
So I've declared b = d, but 'theValue b' and 'theValue d' are different
because theValue is looking at the static type of its argument?
What's to stop 'instance TheValue Base' applying in 'theValue d'?
--
Ashley
Ashley Yakeley writes:
> At 2001-01-16 10:23, Magnus Carlsson wrote:
>
> >You can use overloading for the definition of theValue instead:
> >
> > class TheValue a where theValue :: a -> Maybe Int
> >
> > instance TheValue Basewhere theValue _ = Nothing
> > instance TheValue Derived
At 2001-01-16 10:23, Magnus Carlsson wrote:
>You can use overloading for the definition of theValue instead:
>
> class TheValue a where theValue :: a -> Maybe Int
>
> instance TheValue Basewhere theValue _ = Nothing
> instance TheValue Derived where theValue x = Just (x.value)
Doesn't thi
Magnus Carlsson wrote:
>
> You can use overloading for the definition of theValue instead:
>
> class TheValue a where theValue :: a -> Maybe Int
>
> instance TheValue Basewhere theValue _ = Nothing
> instance TheValue Derived where theValue x = Just (x.value)
>
... or rather, you wi
You can use overloading for the definition of theValue instead:
class TheValue a where theValue :: a -> Maybe Int
instance TheValue Basewhere theValue _ = Nothing
instance TheValue Derived where theValue x = Just (x.value)
/M
Ashley Yakeley writes:
> How do you do OOP-style polymorp
At 2001-01-16 00:03, Johan Nordlander wrote:
>Ashley Yakeley wrote:
>>
>> How do you do OOP-style polymorphic functions in O'Haskell? My first
>> attempt looked something like this:
>>
>> struct Base
>>
>> struct Derived < Base =
>> value :: Int
>>
>> theValue :: Base -> Maybe Int
>> the
Ashley Yakeley wrote:
>
> How do you do OOP-style polymorphic functions in O'Haskell? My first
> attempt looked something like this:
>
> struct Base
>
> struct Derived < Base =
> value :: Int
>
> theValue :: Base -> Maybe Int
> theValue x = Just (x.value) -- problem line
> theValue _ = No
How do you do OOP-style polymorphic functions in O'Haskell? My first
attempt looked something like this:
struct Base
struct Derived < Base =
value :: Int
theValue :: Base -> Maybe Int
theValue x = Just (x.value) -- problem line
theValue _ = Nothing
In the problem line, x is considered t
10 matches
Mail list logo