[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'

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

2010-12-02 Thread Dmitry Kulagin
ry 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 > wrote: >&

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 kn

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

2011-12-07 Thread Dmitry Kulagin
Dec 7, 2011 at 11:48 AM, Dmitry Kulagin > 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 StateA a = StateT SomeState SomeMonad

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

2011-12-07 Thread Dmitry Kulagin
to write something like this: >> >> type StateB a b = StateT SomeOtherState (StateA a) b >> >> Best regards, Øystein Kolsrud >> >> >> On Wed, Dec 7, 2011 at 11:48 AM, Dmitry Kulagin >> wrote: >>> >>> Hi Dan, >>> >>> I a

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

2011-12-07 Thread Dmitry Kulagin
work for mere aliases, but not for full-fledged > type-level non-inductive functions. > And sometimes we intuitively want to use them as such. > > > 2011/12/7 Dmitry Kulagin >> >> > Dmitry, does your code work with LiberalTypeSynonyms extention >> > activate

[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 i

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

2012-11-29 Thread Dmitry Kulagin
al program I'd like to choose between > -- different fold methods, based on some IO context > return $ FoldSTVoid fold > > useFold :: FoldSTVoid -> ST a () > useFold fold' = runFold fold' f > where f _ = return () -- some trivial iterator > > m

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

[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 написал(а): > On Wed, Dec 12, 2012 at 10:40 AM, Clark Gaebel wrote: >> I just did a quick derivation from >> http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 to get >>

[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. C

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 wrote: > Hi Dmitry. > > > I try to implement little typed DSL with functions, but there is a > problem: > > compiler is unable to infer type

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

2013-02-03 Thread Dmitry Kulagin
, 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. I

[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
l1 l2 leq , 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, wrote: > > Dmitry Kulagin wrote: > > I try to implement typed C-lik

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 wrote: > > I think it might be impossible with type families. I don't think it's > > possible to diff

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 Overlapping&Undecidable. 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 wrot