Ryan Ingram | 1 Nov 2011 01:33
Picon

arr considered harmful

I know it's a bit of an 'intentionally provocative' title, but with the recent discussions on Arrows I thought it timely to bring this up.

Most of the conversion from arrow syntax into arrows uses 'arr' to move components around. However, arr is totally opaque to the arrow itself, and prevents describing some very useful objects as arrows.

For example, I would love to be able to use the arrow syntax to define objects of this type:

data Circuit a b where
    Const :: Bool -> Circuit () Bool
    Wire :: Circuit a a
    Delay :: Circuit a a
    And :: Circuit (Bool,Bool) Bool
    Or :: Circuit (Bool,Bool) Bool
    Not :: Circuit Bool Bool
    Then :: Circuit a b -> Circuit b c -> Circuit a c
    Pair :: Circuit a c -> Circuit b d -> Circuit (a,b) (c,d)
    First :: Circuit a b -> Circuit (a,c) (b,c)
    Swap :: Circuit (a,b) (b,a)
    AssocL :: Circuit ((a,b),c) (a,(b,c))
    AssocR :: Circuit (a,(b,c)) ((a,b),c)
    Loop :: Circuit (a,b) (a,c) -> Circuit b c
etc.

Then we can have code that examines this concrete data representation, converts it to VHDL, optimizes it, etc.

However, due to the presence of the opaque 'arr', there's no way to make this type an arrow without adding an 'escape hatch'
    Arr :: (a -> b) -> Circuit a b
which breaks the abstraction: circuit is supposed to represent an actual boolean circuit; (Arr not) is not a valid circuit because we've lost the information about the existence of a 'Not' gate.

The arrow syntax translation uses arr to do plumbing of variables.  I think a promising project would be to figure out exactly what plumbing is needed, and add those functions to a sort of 'PrimitiveArrow' class.  All of these plumbing functions are trivially implemented in terms of 'arr', when it exists, but if it doesn't, it should be possible to use the arrow syntax regardless.

  -- ryan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Daniel Peebles | 1 Nov 2011 01:44
Picon
Gravatar

Re: arr considered harmful

Have you seen Adam Megacz's work on generalized arrows? I think he proposes to kill arr and has done a decent amount of work on it.

On Mon, Oct 31, 2011 at 8:33 PM, Ryan Ingram <ryani.spam <at> gmail.com> wrote:
I know it's a bit of an 'intentionally provocative' title, but with the recent discussions on Arrows I thought it timely to bring this up.

Most of the conversion from arrow syntax into arrows uses 'arr' to move components around. However, arr is totally opaque to the arrow itself, and prevents describing some very useful objects as arrows.

For example, I would love to be able to use the arrow syntax to define objects of this type:

data Circuit a b where
    Const :: Bool -> Circuit () Bool
    Wire :: Circuit a a
    Delay :: Circuit a a
    And :: Circuit (Bool,Bool) Bool
    Or :: Circuit (Bool,Bool) Bool
    Not :: Circuit Bool Bool
    Then :: Circuit a b -> Circuit b c -> Circuit a c
    Pair :: Circuit a c -> Circuit b d -> Circuit (a,b) (c,d)
    First :: Circuit a b -> Circuit (a,c) (b,c)
    Swap :: Circuit (a,b) (b,a)
    AssocL :: Circuit ((a,b),c) (a,(b,c))
    AssocR :: Circuit (a,(b,c)) ((a,b),c)
    Loop :: Circuit (a,b) (a,c) -> Circuit b c
etc.

Then we can have code that examines this concrete data representation, converts it to VHDL, optimizes it, etc.

However, due to the presence of the opaque 'arr', there's no way to make this type an arrow without adding an 'escape hatch'
    Arr :: (a -> b) -> Circuit a b
which breaks the abstraction: circuit is supposed to represent an actual boolean circuit; (Arr not) is not a valid circuit because we've lost the information about the existence of a 'Not' gate.

The arrow syntax translation uses arr to do plumbing of variables.  I think a promising project would be to figure out exactly what plumbing is needed, and add those functions to a sort of 'PrimitiveArrow' class.  All of these plumbing functions are trivially implemented in terms of 'arr', when it exists, but if it doesn't, it should be possible to use the arrow syntax regardless.

  -- ryan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Felipe Almeida Lessa | 1 Nov 2011 01:48
Picon
Gravatar

Re: arr considered harmful

On Mon, Oct 31, 2011 at 10:33 PM, Ryan Ingram <ryani.spam <at> gmail.com> wrote:
> The arrow syntax translation uses arr to do plumbing of variables.  I think
> a promising project would be to figure out exactly what plumbing is needed,
> and add those functions to a sort of 'PrimitiveArrow' class.  All of these
> plumbing functions are trivially implemented in terms of 'arr', when it
> exists, but if it doesn't, it should be possible to use the arrow syntax
> regardless.

There are already generalized arrows [1].  Is that what you are looking for?

Cheers,

[1] http://www.cs.berkeley.edu/~megacz/garrows/

--

-- 
Felipe.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Ryan Ingram | 1 Nov 2011 02:49
Picon

Re: arr considered harmful

This seems basically what I'm talking about, except even more hardcore.  I think mostly what I'm suggesting is that the GHC arrow preprocessor to compile to something like generalized arrows, by default, with current Arrows as a special case.

  -- ryan

On Mon, Oct 31, 2011 at 5:48 PM, Felipe Almeida Lessa <felipe.lessa <at> gmail.com> wrote:
On Mon, Oct 31, 2011 at 10:33 PM, Ryan Ingram <ryani.spam <at> gmail.com> wrote:
> The arrow syntax translation uses arr to do plumbing of variables.  I think
> a promising project would be to figure out exactly what plumbing is needed,
> and add those functions to a sort of 'PrimitiveArrow' class.  All of these
> plumbing functions are trivially implemented in terms of 'arr', when it
> exists, but if it doesn't, it should be possible to use the arrow syntax
> regardless.

There are already generalized arrows [1].  Is that what you are looking for?

Cheers,

[1] http://www.cs.berkeley.edu/~megacz/garrows/

--
Felipe.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Paterson, Ross | 1 Nov 2011 02:52
Picon
Favicon

Re: arr considered harmful

Ryan Ingram writes:
> Most of the conversion from arrow syntax into arrows uses 'arr' to move components around. However, arr is
totally opaque to the arrow itself, and prevents describing some very useful objects as arrows.

> For example, I would love to be able to use the arrow syntax to define objects of this type:

> data Circuit a b where
>     Const :: Bool -> Circuit () Bool
>     Wire :: Circuit a a
>     Delay :: Circuit a a
>     And :: Circuit (Bool,Bool) Bool
>     Or :: Circuit (Bool,Bool) Bool
>     Not :: Circuit Bool Bool
>     Then :: Circuit a b -> Circuit b c -> Circuit a c
>     Pair :: Circuit a c -> Circuit b d -> Circuit (a,b) (c,d)
>     First :: Circuit a b -> Circuit (a,c) (b,c)
>     Swap :: Circuit (a,b) (b,a)
>     AssocL :: Circuit ((a,b),c) (a,(b,c))
>     AssocR :: Circuit (a,(b,c)) ((a,b),c)
>     Loop :: Circuit (a,b) (a,c) -> Circuit b c
> etc.

> Then we can have code that examines this concrete data representation, converts it to VHDL, optimizes it, etc.

> However, due to the presence of the opaque 'arr', there's no way to make this type an arrow without adding an
'escape hatch'
>     Arr :: (a -> b) -> Circuit a b
> which breaks the abstraction: circuit is supposed to represent an actual boolean circuit; (Arr not) is
not a valid circuit because we've lost the information about the existence of a 'Not' gate.

If you require the circuit to be parametric in the value types, you can limit the types of function you can
pass to arr to simple plumbing.
See the netlist example at the end of my "Fun of Programming" slides (http://www.soi.city.ac.uk/~ross/papers/fop.html).
Ryan Newton | 1 Nov 2011 03:03
Picon
Gravatar

Re: Amazon AWS storage best to use with Haskell?

 Any example code of using hscassandra package would really help!

I'll ask my student.  We may have some simple examples.

Also, I have no idea as to their quality but I was pleasantly surprised to find three different amazon related packages on Hackage (simply by searching for the word "Amazon" in the package list).  


It would be great to know if these work.

 -Ryan
   
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Magicloud Magiclouds | 1 Nov 2011 06:07
Picon

ghc 7.2.1 Generics problem

Hi,
  I do not know why, my ghc 7.2.1 does not seem to support
DeriveRepresentable. I compiled the ghc 7.2.1 myself by ghc 7.0.4. All
options default.

$ ghc Types/TopTalkerRecord.hs

Types/TopTalkerRecord.hs:2:14:
    Unsupported extension: DeriveRepresentable

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.2.1
--

-- 
竹密岂妨流水过
山高哪阻野云飞

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Andres Löh | 1 Nov 2011 06:59

Re: ghc 7.2.1 Generics problem

Hi.

>  I do not know why, my ghc 7.2.1 does not seem to support
> DeriveRepresentable. I compiled the ghc 7.2.1 myself by ghc 7.0.4. All
> options default.
>
> $ ghc Types/TopTalkerRecord.hs
>
> Types/TopTalkerRecord.hs:2:14:
>    Unsupported extension: DeriveRepresentable

There's no extension of that name in 7.2.1. Do you mean DeriveGeneric?

Cheers,
  Andres
Ivan Lazar Miljenovic | 1 Nov 2011 06:59
Picon
Gravatar

Re: ghc 7.2.1 Generics problem

On 1 November 2011 16:07, Magicloud Magiclouds
<magicloud.magiclouds <at> gmail.com> wrote:
> Hi,
>  I do not know why, my ghc 7.2.1 does not seem to support
> DeriveRepresentable. I compiled the ghc 7.2.1 myself by ghc 7.0.4. All
> options default.
>
> $ ghc Types/TopTalkerRecord.hs
>
> Types/TopTalkerRecord.hs:2:14:
>    Unsupported extension: DeriveRepresentable
>
> $ ghc --version
> The Glorious Glasgow Haskell Compilation System, version 7.2.1

All I can find about DeriveRepresentable is a patch submitted in April
[1].  However, it seems [2] that it has been renamed to DeriveGenerics

[1]: http://www.haskell.org/pipermail/cvs-ghc/2011-April/061666.html
[2]: http://code.galois.com/cgi-bin/gitweb?p=type-naturals/base.git;a=commitdiff;h=792a8b86185d4cc74bb3d0d31b481ff0de4cf0d6

--

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic <at> gmail.com
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Jason Dagit | 1 Nov 2011 07:12
Picon
Gravatar

Re: blog software in Haskell?

On Mon, Oct 31, 2011 at 2:14 AM, Ketil Malde <ketil <at> malde.org> wrote:
>
> Hi,
>
> I just upgraded my server, and set up everything again.  Except
> wordpress, as 1) I'm not too fond of its user interface, and 2) it's a
> big pile of PHP, difficult to keep updated, and basically a disaster
> waiting to happen (and in fact, it was hacked at one point).
>
> Before I enable it again, is there any alternatives I should consider?
> Preferably written in Haskell, of course, but other suggestions welcome
> as well.

Not in Haskell, but it looks really promising (and it's driven by
version control), I give you Octopress:
http://octopress.org/

It's basically jekyll + github.  Who knows, maybe you can use Hakyll
instead of jekyll.

Since you didn't ask for it, I'll include my $0.02 :)

I don't worry about my blog being written in Haskell because I don't
actually want to spend any time shaving yaks related to running my
blog.  I use blogspot.  It's not great but I pay $0/year and someone
else deals with the issues of keeping it secure, keeping it backed up,
etc.

If you find a cool solution, let us know.

Jason

Gmane