Re: [Haskell-cafe] pointfree-trouble

2009-12-24 Thread Daniel Fischer
Am Freitag 25 Dezember 2009 00:19:58 schrieb Mark Lentczner: > For the record, all of these compile with -O to exactly the same code! > > > reMatr1 f m = Matr (f (unMatr m)) > > reMatr2 f m = Matr $ f $ unMatr m > > reMatr3 f m = Matr . f . unMatr $ m > > reMatr4 f = Matr . f . unMatr > > reMatr5

Re: [Haskell-cafe] pointfree-trouble

2009-12-24 Thread Mark Lentczner
For the record, all of these compile with -O to exactly the same code! > reMatr1 f m = Matr (f (unMatr m)) > reMatr2 f m = Matr $ f $ unMatr m > reMatr3 f m = Matr . f . unMatr $ m > reMatr4 f = Matr . f . unMatr > reMatr5 f = Matr . (flip (.) unMatr) f > reMatr6 = (Matr .) . (. unMatr) A

Re: [Haskell-cafe] pointfree-trouble

2009-12-23 Thread Daniel Fischer
Am Mittwoch 23 Dezember 2009 14:40:46 schrieb slemi: > i dont know any calculus-thingy, this is what i did: > > reMatr a = Matr . a . unMatr > reMatr a = Matr . (. unMatr) a > reMatr a = Matr . (flip (.) unMatr) a You need to be aware of the implicit parentheses, that is Matr . ((flip (.) unMatr)

Re: [Haskell-cafe] pointfree-trouble

2009-12-23 Thread slemi
i dont know any calculus-thingy, this is what i did: reMatr a = Matr . a . unMatr reMatr a = Matr . (. unMatr) a reMatr a = Matr . (flip (.) unMatr) a reMatr = Matr . (flip (.) unMatr) as http://old.nabble.com/pointfree-trouble-td26881661.html#a26889388 Daniel pointed out, this doesnt work bec

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Kim-Ee Yeoh
There you have it: fully- and semi-pointfree versions of reMatr. A heads up: aggressively pursuing pointfreeness without type signatures guarantees a courtesy call from the monomorphism restriction, pace ()-garlic aficionados. As for your question on why the original code doesn't typecheck: if y

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Daniel Fischer
Am Dienstag 22 Dezember 2009 15:09:34 schrieb slemi: > hello everybody, i'm a newbie this is my first post here.. > > i have trouble making a function pointfree: > > data RealFrac a => Matrix a = Matr [[a]] | Scalar a > deriving (Show, Eq) > > unMatr :: RealFrac a => Matrix a -> [[a]] > unMatr =

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Chaddaï Fouché
On Tue, Dec 22, 2009 at 3:09 PM, slemi <0sle...@gmail.com> wrote: > this works fine, but if i leave the 'a' in the last function's definition > like this: > reMatr = Matr . (flip (.) unMatr) The correct point free version would be : > reMatr = (Matr .) . (. unMatr) -- Jedaï

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Felipe Lessa
On Tue, Dec 22, 2009 at 09:27:47AM -0500, Keith Sheppard wrote: > Hello, I didn't try to understand what the function is doing, but just > quickly noticed that > > > reMatr a = Matr . (flip (.) unMatr) a > > can be written as > > reMatr a = Matr . ((flip (.) unMatr) a) ...and then > reMatr a = (M

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Felipe Lessa
On Tue, Dec 22, 2009 at 12:50:26AM -0800, Kim-Ee Yeoh wrote: > reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) > reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with > newtypes And usually we would call this 'liftMatr' or something along these lines. The func

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Keith Sheppard
Hello, I didn't try to understand what the function is doing, but just quickly noticed that > reMatr a = Matr . (flip (.) unMatr) a can be written as > reMatr a = Matr . ((flip (.) unMatr) a) but that > reMatr = Matr . (flip (.) unMatr) can be written as > reMatr a = (Matr . (flip (.) unMatr))

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread slemi
thanks, that's a really neat syntactic sugar :) however, my original question was how to make the reMatr function pointfree, as reMatr = Matr . (flip (.) unMatr) is not working. any ideas/explanation why it doesnt work? Kim-Ee Yeoh wrote: > > Here's another way of writing it: > > data Matrix

[Haskell-cafe] pointfree-trouble

2009-12-22 Thread slemi
hello everybody, i'm a newbie this is my first post here.. i have trouble making a function pointfree: data RealFrac a => Matrix a = Matr [[a]] | Scalar a deriving (Show, Eq) unMatr :: RealFrac a => Matrix a -> [[a]] unMatr = (\(Matr a) -> a) reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matr

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Kim-Ee Yeoh
Here's another way of writing it: data Matrix a = Matr {unMatr :: [[a]]} | Scalar a deriving (Show, Eq) -- RealFrac constraint removed reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with newtypes Affixing con