Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-14 Thread Ozgur Akgun
Oh well, thanks for all the response. I have a module with lots of one line function definitons, and they just *look* ugly when I wrap the return type with Maybe. This is a straightforward, and trivial job (the conversion) and I really don't care about other problems (such as non-termination plus

Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-14 Thread Roel van Dijk
On Wed, Apr 14, 2010 at 2:32 AM, Ivan Miljenovic wrote: > Why not use Maybe for func1 in the first place?  Or are you wanting to > automagically make all uses of head, tail, etc. safe? In which case there is already the 'safe' package: http://hackage.haskell.org/package/safe _

Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-13 Thread Ivan Miljenovic
On 13 April 2010 20:02, Ozgur Akgun wrote: > func1 :: T -> T > func1 A = B > > func1Fixed :: T -> Maybe T > func1Fixed A = Just B > func1Fixed _ = Nothing Why not use Maybe for func1 in the first place? Or are you wanting to automagically make all uses of head, tail, etc. safe? -- Ivan Lazar

Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-13 Thread Daniel Schoepe
Excerpts from Ozgur Akgun's message of Tue Apr 13 12:02:06 +0200 2010: > Cafe, > > Is there a way (without going into the IO lands) to achieve this: > [..] There's package for that on hackage: http://hackage.haskell.org/packages/archive/spoon/0.3/doc/html/Control-Spoon.html However, this is some

[Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-13 Thread Ozgur Akgun
Cafe, Is there a way (without going into the IO lands) to achieve this: data T = A | B | C func1 :: T -> T func1 A = B func1Fixed :: T -> Maybe T func1Fixed A = Just B func1Fixed _ = Nothing I want a function to generate func1Fixed, given func1. I guess this is doable with exception handling