[Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Peter Verswyvelen
Haskell seems to have pretty strong support for dynamic casting using
Data.Typeable and Data.Dynamic.
All kinds of funky dynamic programming seems to be possible with these
hacks.

Is this considered as being as bad as - say - unsafePerformIO? What kind of
evil is lurking here?

Cheers,
Peter
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Don Stewart
bugfact:
 Haskell seems to have pretty strong support for dynamic casting using
 Data.Typeable and Data.Dynamic.
 
 All kinds of funky dynamic programming seems to be possible with these
 hacks. 
 
 Is this considered as being as bad as - say - unsafePerformIO? What kind of
 evil is lurking here?

Inefficiencies and runtime errors?

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Lennart Augustsson
They are not unsafe in the way unsafePerformIO is, but I regard them
as a last resort in certain situations.
Still, in those situations they are very useful.

  -- Lennart

2009/2/12 Peter Verswyvelen bugf...@gmail.com:
 Haskell seems to have pretty strong support for dynamic casting using
 Data.Typeable and Data.Dynamic.
 All kinds of funky dynamic programming seems to be possible with these
 hacks.
 Is this considered as being as bad as - say - unsafePerformIO? What kind of
 evil is lurking here?
 Cheers,
 Peter


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Jonathan Cast
On Thu, 2009-02-12 at 19:04 +0100, Lennart Augustsson wrote:
 They are not unsafe in the way unsafePerformIO is,

I beg permission to demur:

  newtype Unsafe alpha = Unsafe { unUnsafe :: alpha }
  instance Typeable (Unsafe alpha) where
typeOf _ = typeOf ()

  pseudoSafeCoerce :: alpha - Maybe beta
  pseudoSafeCoerce = fmap unUnsafe . cast . Unsafe

Note that

  pseudoSafeCoerce = Just . unsafeCoerce

 but I regard them
 as a last resort in certain situations.
 Still, in those situations they are very useful.

But I would agree with both of these.  As long as you *derive* Typeable.

jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Lennart Augustsson
You're quite right.  You should only be allowed to derive Typeable.
(Which could be arranged by hiding the methods of typeable.)

On Thu, Feb 12, 2009 at 6:24 PM, Jonathan Cast
jonathancc...@fastmail.fm wrote:
 On Thu, 2009-02-12 at 19:04 +0100, Lennart Augustsson wrote:
 They are not unsafe in the way unsafePerformIO is,

 I beg permission to demur:

  newtype Unsafe alpha = Unsafe { unUnsafe :: alpha }
  instance Typeable (Unsafe alpha) where
typeOf _ = typeOf ()

  pseudoSafeCoerce :: alpha - Maybe beta
  pseudoSafeCoerce = fmap unUnsafe . cast . Unsafe

 Note that

  pseudoSafeCoerce = Just . unsafeCoerce

 but I regard them
 as a last resort in certain situations.
 Still, in those situations they are very useful.

 But I would agree with both of these.  As long as you *derive* Typeable.

 jcc


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Peter Verswyvelen
It would be interesting to see when you HAVE to use dynamics, e.g. when no
other solution is possible in Haskell...
Right now if I use it, it feels that I'm doing so because I'm too new to
Haskell.


On Thu, Feb 12, 2009 at 7:53 PM, Lennart Augustsson
lenn...@augustsson.netwrote:

 You're quite right.  You should only be allowed to derive Typeable.
 (Which could be arranged by hiding the methods of typeable.)

 On Thu, Feb 12, 2009 at 6:24 PM, Jonathan Cast
 jonathancc...@fastmail.fm wrote:
  On Thu, 2009-02-12 at 19:04 +0100, Lennart Augustsson wrote:
  They are not unsafe in the way unsafePerformIO is,
 
  I beg permission to demur:
 
   newtype Unsafe alpha = Unsafe { unUnsafe :: alpha }
   instance Typeable (Unsafe alpha) where
 typeOf _ = typeOf ()
 
   pseudoSafeCoerce :: alpha - Maybe beta
   pseudoSafeCoerce = fmap unUnsafe . cast . Unsafe
 
  Note that
 
   pseudoSafeCoerce = Just . unsafeCoerce
 
  but I regard them
  as a last resort in certain situations.
  Still, in those situations they are very useful.
 
  But I would agree with both of these.  As long as you *derive* Typeable.
 
  jcc
 
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Don Stewart
Notably, extensible exceptions use dynamics, in conjunction with type
classes and existentials.

A number of solutions to the 'expression problem' involve dynamics.

bugfact:
 It would be interesting to see when you HAVE to use dynamics, e.g. when no
 other solution is possible in Haskell...
 
 Right now if I use it, it feels that I'm doing so because I'm too new to
 Haskell.
 
 
 On Thu, Feb 12, 2009 at 7:53 PM, Lennart Augustsson lenn...@augustsson.net
 wrote:
 
 You're quite right.  You should only be allowed to derive Typeable.
 (Which could be arranged by hiding the methods of typeable.)
 
 On Thu, Feb 12, 2009 at 6:24 PM, Jonathan Cast
 jonathancc...@fastmail.fm wrote:
  On Thu, 2009-02-12 at 19:04 +0100, Lennart Augustsson wrote:
  They are not unsafe in the way unsafePerformIO is,
 
  I beg permission to demur:
 
   newtype Unsafe alpha = Unsafe { unUnsafe :: alpha }
   instance Typeable (Unsafe alpha) where
 typeOf _ = typeOf ()
 
   pseudoSafeCoerce :: alpha - Maybe beta
   pseudoSafeCoerce = fmap unUnsafe . cast . Unsafe
 
  Note that
 
   pseudoSafeCoerce = Just . unsafeCoerce
 
  but I regard them
  as a last resort in certain situations.
  Still, in those situations they are very useful.
 
  But I would agree with both of these.  As long as you *derive* Typeable.
 
  jcc
 
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is using Data.Dynamic considered a no-go?

2009-02-12 Thread Sterling Clover
SYB makes very heavy use of Typeable as well, although not, as I  
recall dynamics as such.


Cheers,
Sterl.

On Feb 12, 2009, at 3:40 PM, Don Stewart wrote:


Notably, extensible exceptions use dynamics, in conjunction with type
classes and existentials.

A number of solutions to the 'expression problem' involve dynamics.

bugfact:
It would be interesting to see when you HAVE to use dynamics, e.g.  
when no

other solution is possible in Haskell...

Right now if I use it, it feels that I'm doing so because I'm too  
new to

Haskell.


On Thu, Feb 12, 2009 at 7:53 PM, Lennart Augustsson  
lenn...@augustsson.net

wrote:

You're quite right.  You should only be allowed to derive  
Typeable.

(Which could be arranged by hiding the methods of typeable.)

On Thu, Feb 12, 2009 at 6:24 PM, Jonathan Cast
jonathancc...@fastmail.fm wrote:

On Thu, 2009-02-12 at 19:04 +0100, Lennart Augustsson wrote:

They are not unsafe in the way unsafePerformIO is,


I beg permission to demur:

 newtype Unsafe alpha = Unsafe { unUnsafe :: alpha }
 instance Typeable (Unsafe alpha) where
   typeOf _ = typeOf ()

 pseudoSafeCoerce :: alpha - Maybe beta
 pseudoSafeCoerce = fmap unUnsafe . cast . Unsafe

Note that

 pseudoSafeCoerce = Just . unsafeCoerce


but I regard them
as a last resort in certain situations.
Still, in those situations they are very useful.


But I would agree with both of these.  As long as you *derive*  
Typeable.


jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe