[Haskell-cafe] Out of memory if compiled with -O2, why?

2010-12-01 Thread Dmitry Kulagin
Hi, I have problems with memory leaks and can't find out how to avoid them. I tried to reduce sample to demonstrate the following problems: 1) when compiled without -O2 option, it iconsumes 1582MB (!) total memory 2) when compiled with -O2 option it terminates with out of memory Actually I don't

Re: [Haskell-cafe] Out of memory if compiled with -O2, why?

2010-12-02 Thread Dmitry Kulagin
is taken by the list returned by your lst function wich is being shared across g,h,i,j,k,l,m,n. Apparently there is no safe and easy way to overcome this yet :( -- Regards, Petr On Wed, Dec 1, 2010 at 5:23 PM, Dmitry Kulagin dmitry.kula...@gmail.com wrote: Hi, I have problems

Re: [Haskell-cafe] More liberal than liberal type synonyms

2011-12-07 Thread Dmitry Kulagin
Hi Dan, I am still pretty new in Haskell, but this problem annoys me already. If I define certain monad as a type synonym: type StateA a = StateT SomeState SomeMonad a Then I can't declare new monad based on the synonym: type StateB a = StateT SomeOtherState StateA a The only way I

Re: [Haskell-cafe] More liberal than liberal type synonyms

2011-12-07 Thread Dmitry Kulagin
You should be able to write something like this: type StateB a b = StateT SomeOtherState (StateA a) b Thank you for reply, but this variant actually does not compile: StateA and (StateA a) have different kinds. Dmitry Best regards, Øystein Kolsrud On Wed, Dec 7, 2011 at 11:48 AM, Dmitry

Re: [Haskell-cafe] More liberal than liberal type synonyms

2011-12-07 Thread Dmitry Kulagin
a b = StateT SomeOtherState (StateA a) b Best regards, Øystein Kolsrud On Wed, Dec 7, 2011 at 11:48 AM, Dmitry Kulagin dmitry.kula...@gmail.com wrote: Hi Dan, I am still pretty new in Haskell, but this problem annoys me already. If I define certain monad as a type synonym:    type

Re: [Haskell-cafe] More liberal than liberal type synonyms

2011-12-07 Thread Dmitry Kulagin
. And sometimes we intuitively want to use them as such. 2011/12/7 Dmitry Kulagin dmitry.kula...@gmail.com Dmitry, does your code work with LiberalTypeSynonyms extention activated? No, the same error: Type synonym `StateA' should have 1 argument, but has been given 0 But I have GHC 6.12.3 Dmitry

[Haskell-cafe] Can not use ST monad with polymorphic function

2012-11-28 Thread Dmitry Kulagin
Hi Cafe, I try to implement some sort of monadic fold, where traversing is polymorphic over monad type. The problem is that the code below does not compile. It works with any monad except for ST. I suspect that monomorphism is at work here, but it is unclear for me how to change the code to make

Re: [Haskell-cafe] Can not use ST monad with polymorphic function

2012-11-29 Thread Dmitry Kulagin
return $ FoldSTVoid fold useFold :: FoldSTVoid - ST a () useFold fold' = runFold fold' f where f _ = return () -- some trivial iterator main = do fold'' - selectFold some-method-id print $ runST $ useFold fold'' On Nov 28, 2012, at 9:52 PM, Dmitry Kulagin dmitry.kula...@gmail.com

Re: [Haskell-cafe] Can not use ST monad with polymorphic function

2012-12-03 Thread Dmitry Kulagin
Basically, quantified types can't be given as arguments to type constructors (other than -, which is its own thing). I'm not entirely sure why, but it apparently makes the type system very complicated from a theoretical standpoint. By wrapping the quantified type in a newtype, the argument

[Haskell-cafe] containers license issue

2012-12-12 Thread Dmitry Kulagin
Hi Cafe, I am faced with unpleasant problem. The lawyer of my company checked sources of containers package and found out that it refers to some GPL-library. Here is quote: The algorithm is derived from Jorg Arndt's FXT library in file Data/IntMap/Base.hs The problem is that FXT library is GPL

Re: [Haskell-cafe] containers license issue

2012-12-12 Thread Dmitry Kulagin
Clark, Johan, thank you! That looks like perfect solution to the problem. 12.12.2012, в 22:56, Johan Tibell johan.tib...@gmail.com написал(а): On Wed, Dec 12, 2012 at 10:40 AM, Clark Gaebel cgae...@uwaterloo.ca wrote: I just did a quick derivation from

[Haskell-cafe] why GHC cannot infer type in this case?

2013-01-31 Thread Dmitry Kulagin
Hi Cafe, I try to implement little typed DSL with functions, but there is a problem: compiler is unable to infer type for my functions. It seems that context is clear, but still GHC complains Could not deduce It is sad because without type inference the DSL will be very difficult to use.

Re: [Haskell-cafe] why GHC cannot infer type in this case?

2013-01-31 Thread Dmitry Kulagin
Andres, thank you! Your response is really helpful. I will try to adopt your suggestion. Thank again! Dmitry On Thu, Jan 31, 2013 at 7:27 PM, Andres Löh and...@well-typed.com wrote: Hi Dmitry. I try to implement little typed DSL with functions, but there is a problem: compiler is

Re: [Haskell-cafe] why GHC cannot infer type in this case?

2013-02-03 Thread Dmitry Kulagin
...@okmij.org wrote: Dmitry Kulagin wrote: I try to implement little typed DSL with functions, but there is a problem: compiler is unable to infer type for my functions. One way to avoid the problem is to start with the tagless final representation. It imposes fewer requirements on the type

[Haskell-cafe] Help to write type-level function

2013-02-26 Thread Dmitry Kulagin
Hi, I try to implement typed C-like structures in my little dsl. I was able to express structures using type-level naturals (type Ty is promoted): data Ty = TInt | TBool | TStruct Symbol [Ty] That allowed to implement all needed functions, including type-level function: type family Get (n ::

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
, HRLabelSet' l1 l2 leq r ) = HRLabelSet (LVPair l1 v1 ': LVPair l2 v2 ': r) so the usage of the extension is unavoidable for my purposes? Thank you! On Wed, Feb 27, 2013 at 12:28 PM, o...@okmij.org wrote: Dmitry Kulagin wrote: I try to implement typed C-like structures in my little dsl

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
Very clear solution, I will try to adopt it. Thank you! On Wed, Feb 27, 2013 at 12:17 PM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 27 February 2013 12:01, Raphael Gaschignard dasur...@gmail.com wrote: I think it might be impossible with type families. I don't think it's

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
Hi Aleksey, Unfortunately, your solution does not work for me (ghc 7.6.2). I reduced the problem to: -- | Type class for type equality. class TypeEq (a :: α) (b :: α) (eq :: Bool) | a b - eq instance TypeEq a a True -- instance TypeEq a b False instance eq ~ False = TypeEq a b eq

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
Oh, that is my fault - I was sure that I specified the extension and it didn't help. It really works with OverlappingUndecidable. Thank you! On Wed, Feb 27, 2013 at 10:36 PM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 27.02.2013 17:35, Dmitry Kulagin wrote: Hi Aleksey