POV-Ray : Newsgroups : povray.off-topic : Lots of statistics : Re: C# Server Time
29 Jul 2024 14:22:01 EDT (-0400)
  Re: C#  
From: Invisible
Date: 14 Aug 2012 10:16:45
Message: <502a5dcd$1@news.povray.org>
>> module Foobar (Foo (..), foobar) where
>>
>> data Foo = Foo Int deriving Show
>> data Bar = Bar Int deriving Show
>>
>> foobar :: Foo -> Bar
>> foobar (Foo x) = Bar x
>
> Correct me if I'm wrong, but apart from showing that the standard
> seemingly allows it, how would you use that in a real world scenario?
>
> By exporting foobar, you intend to use it somewhere else in your code,
> right? Which means there's another piece of code somewhere that expects
> to receive something of type bar, without knowing what type bar actually
> is!
>
> How does that work?

Well, you're right in that you cannot write any code which explicitly 
expects Bar. You can pass the result to any function that works with 
/all/ types, or any function that works with any showable type. If the 
module exported some functions that expect Bar as input, you can pass 
the result to them. But you can't write that in a type signature, 
which... yeah, is a bit silly.

My point wasn't so much that this is a something anybody is likely to 
want to do. My point was a counter-example to the "that's obviously 
impossible" argument. It's /not/ impossible at all.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.