If I have the following type signature
transMit :: Serialize a = Socket - POSIXTime - KEY - Maybe a - TPSQ -
TMap a - IO ()
And the function is called with
transMit s now key newmsgs q m
where newmsgs is whatever type a I get but _not_ a Maybe a
then I get the error
Could not deduce (a ~
Put a Just around it?
transMit s now key (Just newmsgs) q m
On Sat 27 Jul 2013 20:05:43 JST, Joerg Fritsch wrote:
If I have the following type signature
transMit :: Serialize a = Socket - POSIXTime - KEY - Maybe a - TPSQ -
TMap a - IO ()
And the function is called with
transMit s now key
Hi Vlatko.
On 2 July 2013 16:03, Vlatko Basic vlatko.ba...@gmail.com wrote:
Is there a nicer way to extract the 'IO String' from 'IOS',
without 'case' or without pattern matching the whole 'P'?
You might enjoy the newtype package.
http://hackage.haskell.org/package/newtype
Hope this helps,
of
IOS a - a
getC_IO (P _ _ (IOS a)) = a
Original Message
Subject: Re: [Haskell-cafe] Casting newtype to base type?
From: Malcolm Wallace malcolm.wall...@me.com
To: vlatko.ba...@gmail.com
Cc: Haskell-Cafe haskell-cafe@haskell.org
Date: 01.07.2013 17:24
On 1 Jul 2013, at 16:07
On Tue, Jul 02, 2013 at 03:03:08PM +0200, Vlatko Basic wrote:
Is there a nicer way to extract the 'IO String' from 'IOS',
without 'case' or without pattern matching the whole 'P'?
newtype IOS = IOS (IO String)
data P = P {
getA :: String,
getB :: String,
getC :: IOS
} deriving
Original Message
Subject: Re: [Haskell-cafe] Casting newtype to base type?
From: Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk
To: haskell-cafe@haskell.org
Date: 02.07.2013 15:25
On Tue, Jul 02, 2013 at 03:03:08PM +0200, Vlatko Basic wrote:
Is there a nicer way
You could always just put it into your newtype:
newtype IOS = IOS {
unIOS :: IO String
}
On Tue, Jul 2, 2013 at 9:31 AM, Vlatko Basic vlatko.ba...@gmail.com wrote:
Original Message
Subject: Re: [Haskell-cafe] Casting newtype to base type?
From: Tom Ellis tom-lists
Hello Cafe!
I had a (simplified) record
data P = P {
a :: String,
b :: String,
c :: IO String
} deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created
'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String
Am 7/1/2013 5:07 PM, schrieb Vlatko Basic:
to get automatic deriving of 'Show' and 'Eq' for 'data P' I have
created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String
What you really want is
newtype IOS = IOS (IO String)
I.e. a IOS value wraps an IO String.
On Mon, Jul 01, 2013 at 05:07:00PM +0200, Vlatko Basic wrote:
Hello Cafe!
I had a (simplified) record
data P = P {
a :: String,
b :: String,
c :: IO String
} deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have
created 'newtype
On 1 Jul 2013, at 16:07, Vlatko Basic wrote:
I had a (simplified) record
data P = P {
a :: String,
b :: String,
c :: IO String
} deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created
'newtype IOS' and its 'Show' and 'Eq'
Hi Wallace,
yes, indeed. Now I see I mixed newtype with type in declaration, and forgot the
first one is a constructor.
Original Message
Subject: Re: [Haskell-cafe] Casting newtype to base type?
From: Malcolm Wallace malcolm.wall...@me.com
To: vlatko.ba...@gmail.com
Cc
I'm experimenting. The IO field is just a helper field, so it shouldn't have any
consequences.
Original Message
Subject: Re: [Haskell-cafe] Casting newtype to base type?
From: Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk
To: haskell-cafe@haskell.org
Date: 01.07.2013
Hello Thomas,
Monday, October 9, 2006, 3:47:05 PM, you wrote:
constraints on its type. Rather than being just any type that is an
instance of A, I want to do a runtime check and do something different
it's a sort of problem that bites me many times when i start to wrote
Streams library :)
Hi All
I'm having some difficulty with typeclasses.
What I'm trying to do should be obvious, but it's still giving me
trouble. I want to take a packaged item, and strengthen the
constraints on its type. Rather than being just any type that is an
instance of A, I want to do a runtime check and
Thomas Conway wrote:
I'm having some difficulty with typeclasses.
What I'm trying to do should be obvious, but it's still giving me
trouble. I want to take a packaged item, and strengthen the
constraints on its type. Rather than being just any type that is an
instance of A, I want to do a
Thanks Misha Matthias.
I now get what's going on. The mention of the word dictionary
revealed it all. I've spent the last 7 years programming in C++, and
had dynamic_cast firmly fixed in my head. I totally forgot that
Fergus Henderson and I independently reinvented dictionary passing for
the
Subject: Re: [Haskell-cafe] casting numerical types
Arbitrary numerical types don't support division. (They're rings, not
fields.) The
(Fractional a) = [a] - a
type is the best you can do.
- Cale
On 01/04/06, Matthias Fischmann [EMAIL PROTECTED] wrote:
hi all,
this should
Matthias Fischmann [EMAIL PROTECTED] writes:
avg :: (FractionalOrIntegral a) = [a] - a
avg xs = sum (map fromFractionalOrIntegral xs) / (fromIntegral (length xs))
Your condition is probably too strong. For one thing, there is no need
to convert every element of the list being summed,
On Sun, Apr 02, 2006 at 10:53:02AM +0100, Malcolm Wallace wrote:
To: haskell-cafe@haskell.org
From: Malcolm Wallace [EMAIL PROTECTED]
Date: Sun, 2 Apr 2006 10:53:02 +0100
Subject: Re: [Haskell-cafe] casting numerical types
Matthias Fischmann [EMAIL PROTECTED] writes:
avg
Arbitrary numerical types don't support division. (They're rings, not
fields.) The
(Fractional a) = [a] - a
type is the best you can do.
- Cale
On 01/04/06, Matthias Fischmann [EMAIL PROTECTED] wrote:
hi all,
this should be a quick one (for now I would be happy with a that's
impossible,
21 matches
Mail list logo