
instance (BinaryDefer a, BinaryDefer b) => BinaryDefer (a,b) where put (a,b) = put2 a b get = get2 (,) size x = let ~(a,b) = x in size a + size b putFixed (a,b) = putFixed2 a b getFixed = getFixed2 (,) in `size` function, what does the `~` mean ? Sincerely! ----- fac n = let { f = foldr (*) 1 [1..n] } in f -- View this message in context: http://old.nabble.com/what-does-the-%27%7E%27-mean---tp28263383p28263383.htm... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On 16 April 2010 15:59, zaxis
instance (BinaryDefer a, BinaryDefer b) => BinaryDefer (a,b) where put (a,b) = put2 a b get = get2 (,) size x = let ~(a,b) = x in size a + size b putFixed (a,b) = putFixed2 a b getFixed = getFixed2 (,)
in `size` function, what does the `~` mean ?
A lazy pattern match: http://en.wikibooks.org/wiki/Haskell/Laziness (there is a better name for it, but I can't remember). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Ivan,
in `size` function, what does the `~` mean ?
A lazy pattern match: http://en.wikibooks.org/wiki/Haskell/Laziness (there is a better name for it, but I can't remember).
Irrefutable pattern? ;-) Cheers, Stefan

On 16/04/10 07:09, Ivan Miljenovic wrote:
On 16 April 2010 15:59, zaxis
wrote: instance (BinaryDefer a, BinaryDefer b) => BinaryDefer (a,b) where put (a,b) = put2 a b get = get2 (,) size x = let ~(a,b) = x in size a + size b putFixed (a,b) = putFixed2 a b getFixed = getFixed2 (,)
in `size` function, what does the `~` mean ?
A lazy pattern match: http://en.wikibooks.org/wiki/Haskell/Laziness (there is a better name for it, but I can't remember).
Irrefutable patterns? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

On Thu, Apr 15, 2010 at 10:59 PM, zaxis
instance (BinaryDefer a, BinaryDefer b) => BinaryDefer (a,b) where put (a,b) = put2 a b get = get2 (,) size x = let ~(a,b) = x in size a + size b putFixed (a,b) = putFixed2 a b getFixed = getFixed2 (,)
in `size` function, what does the `~` mean ?
This is kind of a funny question, because in this case the ~ doesn't mean anything at all. Pattern matches in let are automatically irrefutable/lazy. A better way to write this is size ~(a,b) = size a + size b which is equivalent to size x = size a + size b where (a,b) = x which is equivalent to size x = let (a,b) = x in size a + size b which is equivalent to size x = let a = case x of (v,_) -> v b = case x of (_,v) -> v in size a + size b If a or b never get evaluated, the case statements (which will fail on bottom values) don't happen.
participants (6)
-
Ivan Lazar Miljenovic
-
Ivan Miljenovic
-
Magnus Therning
-
Ryan Ingram
-
Stefan Holdermans
-
zaxis