Re: [Haskell-cafe] a library for abstract algebra?

2013-04-19 Thread Mikhail Glushenkov
Hi,

Petr Pudlák  gmail.com> writes:

> 
> Hi,
> is there a Haskell library for defining and working with algebraic
structures [...] ?

There is also http://hackage.haskell.org/package/HaskellForMaths



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Safe Haskell and instance coherence

2012-10-17 Thread Mikhail Glushenkov
Hello David,

On Thu, Oct 18, 2012 at 6:21 AM, David Mazieres expires 2013-01-15 PST

wrote:
>
> What's interesting is that these examples doesn't violate the goals of
> Safe Haskell--i.e., they don't violate type safety, encapsulation, or
> semantic consistency as we defined it--but they are worrisome.

I think that my example violates encapsulation in a similar way to how
GND violates encapsulation in the MinList example from the Safe
Haskell paper.

IIUC, the problem is that all instances are assumed to be coherent
(that's why it's an error to have two Monoid Int instances in the same
module), but this assumption isn't actually enforced across module
boundaries, even though it is reflected in the type system. GHC does
print a warning after having encountered orphan instances, but that's
all.

> This is essentially the same thing as my Monoid example.  You've got
> two different dictionaries for the same type, and can pass either one
> around depending on what module you imported.

Are "dictionaries" something that is a part of Haskell semantics or an
artefact of the implementation?

> It's
> not hard to cook up a contrived example where some sort of security
> monitor hands over the keys to the kingdom if ever it encounters
> duplicate items in a set.  Auditing the code, that might seem fine
> unless you understand the implementation of Set, which makes reasoning
> about security a lot harder.

Agreed.

> What we really want is for the dictionary to be associated with the
> data structure at the time of creation, not passed in as an argument
> for each operation.  But that's not even implementable without the
> existential types extension, and also would require re-writing all the
> containers, which is absolutely not what we want.

This is what Scala does. Unfortunately, this can make some operations
(e.g. set union) asymptotically less efficient (as it's now impossible
to rely on the fact that both sets use the same associated
dictionary).

> Failing that, I guess we could disallow overlapping instances even
> when they don't overlap in a single module.  This is a whole-program
> check similar to what type families requires, so could possibly be
> implemented in a similar way.

I'm really interested in the link-time check that is performed for
type families. Is it described somewhere?

> However, as with type families, making
> it work with dynamic loading is going to be kind of hard.  Essentially
> there would have to be some run-time inspectable information about all
> instances defined.

I think that's why Rust chose to just disallow orphan instances :-)
Even without dynamic loading, supporting all GHC extensions (e.g.
FlexibleInstances) will probably be non-trivial.


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Safe Haskell and instance coherence

2012-10-17 Thread Mikhail Glushenkov
Hello David,

On Wed, Oct 17, 2012 at 6:02 PM, David Mazieres expires 2013-01-15 PST

wrote:
> Can you elaborate on how this can be used to break the data structure
> invariant?  If in safe Haskell you import two modules that have
> overlapping instances, you will not be able to use the two instances.
> Modules that import only one instance will be able to use that
> instance.

Please take a look at the code example I provided:

https://gist.github.com/3854294

I don't use overlapping instances or any other extensions besides Safe
Haskell. By defining two orphan Ord instances for U I'm able to
construct a value of type Set U that contains two equal elements:

> test
fromList [X,Y,X]

This is what I meant by "breaking the data structure invariant". This
shouldn't normally be possible: the documentation for Data.Set.insert
says: "If the set already contains an element equal to the given
value, it is replaced with the new value."

Regarding your Monoid example, it will still be possible to make it
work even if instance coherence is enforced by using a newtype wrapper
(in fact, Data.Monoid already includes Sum and Product newtype
wrappers that provide this functionality).



-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Safe Haskell and instance coherence

2012-10-11 Thread Mikhail Glushenkov
Hello,

On Thu, Oct 11, 2012 at 4:33 PM, MigMit  wrote:
>
> On Oct 11, 2012, at 6:23 PM, Mikhail Glushenkov 
>  wrote:
>>
>> On Thu, Oct 11, 2012 at 3:54 PM, MigMit  wrote:
>>> You have a bigger problem coming. Some extensions make multiple instances 
>>> OK, even in Safe Haskell. For example:
>>>
>>> {-# LANGUAGE FlexibleInstances, IncoherentInstances, Safe #-}
>>> [...]
>>
>> Safe Haskell already disallows OverlappingInstances.
>
> It doesn't. Overlapping instances are allowed in safe modules, provided that 
> they won't be used in other modules.

I stand corrected. Still, I think that something will have to be done
about IncoherentInstances if the aforementioned restriction will be
added.

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Safe Haskell and instance coherence

2012-10-11 Thread Mikhail Glushenkov
Hello,

On Thu, Oct 11, 2012 at 3:54 PM, MigMit  wrote:
> You have a bigger problem coming. Some extensions make multiple instances OK, 
> even in Safe Haskell. For example:
>
> {-# LANGUAGE FlexibleInstances, IncoherentInstances, Safe #-}
> [...]

Safe Haskell already disallows OverlappingInstances. If we add a
requirement that it must be unambiguous which instance declaration a
given type class constraint resolves to (taking into account instances
defined in all modules), I think it will be necessary to also disallow
IncoherentInstances.

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Safe Haskell and instance coherence

2012-10-11 Thread Mikhail Glushenkov
Hello Simon,

On Thu, Oct 11, 2012 at 11:24 AM, Simon Marlow  wrote:
> On 08/10/2012 20:11, Mikhail Glushenkov wrote:
>> I couldn't find anything on the interplay between orphan instances and
>> Safe Haskell both in the Haskell'12 paper and online. Is this
>> something that the authors of Safe Haskell are aware of/are intending
>> to fix?
>
> [...]
> I don't know what we should do about this.  Disallowing orphan instances
> seems a bit heavy-handed. David, Simon, any thoughts?

What about detecting duplicate instances at link time? We could put
information about all instances defined in a given module into the
.comment section of the corresponding .o file and then have a pre-link
step script extract this information from all .o files in the program
and check that there are no duplicate or conflicting instances.


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Safe Haskell and instance coherence

2012-10-08 Thread Mikhail Glushenkov
Hello,

It's a relatively well-known fact that GHC allows for multiple type
class instances for the same type to coexist in a single program. This
can be used, for example, to construct values of the type Data.Set.Set
that violate the data structure invariant. I was mildly surprised to
find out that this works even when Safe Haskell is turned on:

https://gist.github.com/3854294

Note that the warnings tell us that both instances are "[safe]" which
gives a false sense of security.

I couldn't find anything on the interplay between orphan instances and
Safe Haskell both in the Haskell'12 paper and online. Is this
something that the authors of Safe Haskell are aware of/are intending
to fix?

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Level of Win32 GUI support in the Haskell platform

2011-12-29 Thread Mikhail Glushenkov
Hi,

Steve Horne  blueyonder.co.uk> writes:

> 
> I've been for functions like GetMessage, TranslateMessage and 
> DispatchMessage in the Haskell Platform Win32 library - the usual 
> message loop stuff - and not finding them. Hoogle says "no results found".

Haskell Platform includes the Win32 package which provides access to these
functions. Hoogle doesn't index Windows-only packages, unfortunately.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to make ghc 7 with llvm?

2011-04-29 Thread Mikhail Glushenkov
Henning Thielemann  henning-thielemann.de> writes:
>
> Nontheless it might be interesting to let GHC emit LLVM bitcode. As far as 
> I understand, this would enable LLVM's Link Time Optimizations.

And if you really need .bc, there is always llvm-as.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to make ghc 7 with llvm?

2011-04-29 Thread Mikhail Glushenkov
Hi,

Henning Thielemann  henning-thielemann.de> writes:
>
> Nontheless it might be interesting to let GHC emit LLVM bitcode. As far as 
> I understand, this would enable LLVM's Link Time Optimizations.

You can already emit .ll code with -ddump-llvm. 
All LLVM tools that take .bc files as input (llc/opt/llvm-link) can also read
.ll (look at llvm/Support/IRReader.h).


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: New .hs File Icons

2010-09-04 Thread Mikhail Glushenkov
Christian Eltges  googlemail.com> writes:

> 
> Hello,
> 
> I was wondering why the File-Icon installed by GHC with the lambda for
> .hs files hasn't changed to the new
>
> [...]
>
> So if the only reason for using the old icon was, that there is no new
> one, then you can use this.

Cool, thanks! I'll include this in the next Haskell Platform 
installer.

It'd be also nice to have separate icons for .lhs files - a
differently colored lambda perhaps?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell Platform on Windows - cabal update problems.

2010-09-04 Thread Mikhail Glushenkov
Hi,

Serguey Zefirov  gmail.com> writes:

> 
> I've installed recent Haskell Platform and tried to wrap my head
> around cabal to finally figure out how to use it.
> 
> [...]
> 
> Now it gives me even more interesting error: "cabal.EXE: fromFlag
> NoFlag. Use fromFlagOrDefault"
> 
> Googling doesn't help here. What does it mean and how to get rid of it?
> 

Try removing the 'Application Data/cabal' directory and running
'cabal update'. You probably made a syntax error in the config
file.

Here's a log of what I do after a clean HP install:

E:\>cabal
no command given (try --help)

E:\>cabal install pointfree
Config file path source is default config file.
Config file Application Data\cabal\config not found.
Writing default configuration to Application Data\cabal\config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
cabal: There is no package named pointfree. Perhaps you need to run 'cabal
update' first?

E:\>cabal update
Downloading the latest package list from hackage.haskell.org

E:\>cabal install pointfree
Resolving dependencies...
Downloading pointfree-1.0.3...
Configuring pointfree-1.0.3...
Preprocessing executables for pointfree-1.0.3...
Building pointfree-1.0.3...
[1 of 7] Compiling Plugin.Pl.Common ( Plugin\Pl\Common.hs, dist\build\pointfree\
pointfree-tmp\Plugin\Pl\Common.o )
[2 of 7] Compiling Plugin.Pl.Parser ( Plugin\Pl\Parser.hs, dist\build\pointfree\
pointfree-tmp\Plugin\Pl\Parser.o )
[3 of 7] Compiling Plugin.Pl.PrettyPrinter ( Plugin\Pl\PrettyPrinter.hs, dist\bu
ild\pointfree\pointfree-tmp\Plugin\Pl\PrettyPrinter.o )
[4 of 7] Compiling Plugin.Pl.Transform ( Plugin\Pl\Transform.hs, dist\build\poin
tfree\pointfree-tmp\Plugin\Pl\Transform.o )
[5 of 7] Compiling Plugin.Pl.Rules  ( Plugin\Pl\Rules.hs, dist\build\pointfree\p
ointfree-tmp\Plugin\Pl\Rules.o )
[6 of 7] Compiling Plugin.Pl.Optimize ( Plugin\Pl\Optimize.hs, dist\build\pointf
ree\pointfree-tmp\Plugin\Pl\Optimize.o )
Linking dist\build\pointfree\pointfree.exe ...
Installing executable(s) in E:\\Application Data\cabal\bin

E:\>pointfree 1 + 2
3



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: regex-compat on latest Haskell Platform

2010-08-17 Thread Mikhail Glushenkov
Hi Kevin,

Kevin Jardine  gmail.com> writes:

> 
> I'm running Haskel Platform 2010.2.0.0 and attempting to compile with
> regex-compat under Windows XP.
> [...]

Apparently, you've been bitten by a bug in the installer:

http://trac.haskell.org/haskell-platform/ticket/137

I haven't updated the installer yet, but in the meantime you can
install regex-posix from Hackage (there is a new version out that
should work on Windows out of the box). Do a 'cabal install
regex-posix' followed by 'cabal install --reinstall
regex-compat'.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Building regex-posix for windows

2010-04-15 Thread Mikhail Glushenkov
Hi,

Станислав Черничкин  gmail.com> writes:
> 
> 
> I'm having
> trouble building regex-posix for Windows [...]

See this thread:

http://thread.gmane.org/gmane.comp.lang.haskell.libraries/12721

Basically, you need to checkout the darcs version which includes
C sources for libregex and hack the .cabal file a bit.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell Platform - changing the global install dir

2009-10-06 Thread Mikhail Glushenkov
Hi Paul,

On Tue, Oct 6, 2009 at 9:11 AM, Paul Moore 
> The "ugliness" (a bad word, I agree) was the need to change multiple
> items - (at least) 2 places in the config file and (presumably) the
> PATH entry.
>
> Is that all I need to change?

I'm not a Cabal expert, but it looks like you could just change the
"user-install" setting to True (and alter the PATH variable
accordingly) to achieve what you want.

> OK. But given that I said "install Haskell" in *this* location, I sort
> of expected all my Haskell stuff to go there.

You have a point, maybe we'll change this in the next release. I've
filed a ticket [1].

[1] http://trac.haskell.org/haskell-platform/ticket/97

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell Platform - changing the global install dir

2009-10-05 Thread Mikhail Glushenkov
Hi Paul,

Paul Moore  gmail.com> writes:

> Is there a way I could have specified that I want the global install
> directory in D:\Apps\Haskell? I guess I could hack my cabal\config
> file (and presumably change PATH) but that seems a bit ugly. 

A bit ugly? Why? That's precisely what the config files are for.

> Is the
> use of Program Files even when the install was to somewhere else a
> bug?

Not really, the Windows installer just doesn't tinker with the
default cabal-install install location. There are plans, though,
to implement an "install only for the current user" mode
for the next release.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version?

2009-07-06 Thread Mikhail Glushenkov
Hi Peter,

Peter Verswyvelen  gmail.com> writes:

>  I know GLUT32.DLL is not bundled with the Haskell Platform
> installer, but which GLUT32.DLL should I use?

I compiled a basic example [1] successfully using the DLL
downloaded from [2]. But since that's the first hit in Google,
you've probably already tried it.

Did you put the DLL where GHC can find it? Use $WINDIR\System32
or $WINDIR\SysWOW64 if you're on 64 bit.

[1] http://netsuperbrain.com/blog/wp-content/uploads/2008/11/teapots.hs
[2] http://www.xmission.com/~nate/glut.html

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Converting -fglasgow-exts into LANGUAGE pragmas

2009-03-31 Thread Mikhail Glushenkov
Hi,

Martijn van Steenbergen  van.steenbergen.nl> writes:

> 
> Hello café,
> 
> I want to replace the -fglasgow-exts in the snippet below by LANGUAGE 
> pragmas. Rank2Types alone doesn't suffice. Which do I need to get the 
> snippet to compile?

Works for me with

{-# LANGUAGE Rank2Types, ImpredicativeTypes, LiberalTypeSynonyms  #-}



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Declaring each instance of a typeclass to be also an instance of another typeclass

2009-01-11 Thread Mikhail Glushenkov
Hi,

Is it possible to write something like this:

> {-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
>
> import Control.Monad (liftM)
>
> instance (Monad a) => Functor a where
> fmap = liftM

without having to use UndecidableInstances (and preferably, other type system
extensions too)?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe