Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: structural induction, two lists, simultaneous (Rustom Mody)
2. Re: Deploying a haskell application (not a webapp)
(Michael Orlitzky)
3. Re: Deploying a haskell application (not a webapp)
(Vale Cofer-Shabica)
4. Does/How does GHC/Haskell optimize this ('almost identical
associative expressions', pattern matching reordering) (Pascal Knodel)
----------------------------------------------------------------------
Message: 1
Date: Thu, 18 Dec 2014 19:17:24 +0530
From: Rustom Mody <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] structural induction, two lists,
simultaneous
Message-ID:
<caj+teodxoem-eigv0n7qfve8-rn2dh4dk7mioejn1pmsrd7...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Thu, Dec 18, 2014 at 12:28 PM, Pascal Knodel <[email protected]>
wrote:
>
>
> > (? ys ? (? f,zs ? map f (ys ++ zs) = map f ys ++ map f zs))
> >
> > And now you can see that you want a proof of a one-variable theorem
>
> Thank you, Rustom Mody, that's it, reordering of universal quantifiers.
> By the way, I'm searching for a 'good' book about predicate logic for
> quite some time now.
> One with a strong link to mathematics and the quantification style
> that is used there would be nice. By chance, is there a reference
> (script/paper/book )
> you would recommend?
>
Two predicate calculus books that are particularly my favorites:
1. Dijkstra and Scholtens Predicate Calculus and Program semantics (5th
chapter is logic)
2. Logical Approach to Discrete Math by Gries and Schneider
Second is more of a student textbook
My own attempts (20 year old!) at integrating the Haskell philosophy with
the Dijkstra style of logic described in these books is here:
http://blog.languager.org/2014/09/pugofer.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141218/5f2e0cc4/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 18 Dec 2014 10:39:55 -0500
From: Michael Orlitzky <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Deploying a haskell application (not
a webapp)
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 12/18/2014 03:20 AM, Alan Buxton wrote:
> Oh that's cool. Is there a way to configure this in some file so that when I
> build just this application a particular datadir is used?
The usual Setup.hs is just a dummy file; Cabal even ignores it. But if
you switch to a "custom" build (from "simple") you can do some
preprocessing in Setup.hs:
https://www.haskell.org/cabal/users-guide/developing-packages.html
In the section "More complex packages", it shows you how to add hooks
that get executed before each configure/build/etc stage. If you add a
configure hook that mangles the datadir template, you can override the
default. Here's a Setup.hs that seems to work:
-- Welcome to the jungle, baby.
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.Configure
import Distribution.Simple.InstallDirs
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
my_hooks :: UserHooks
my_hooks = simpleUserHooks { confHook = my_conf_hook }
main :: IO ()
main = defaultMainWithHooks my_hooks
my_conf_hook :: (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfo
my_conf_hook (gpd,hbi) cf = do
lbi <- configure (gpd, hbi) cf
let orig_dirs = installDirTemplates lbi
let my_datadir = toPathTemplate "/foo/bar"
let my_dirs = orig_dirs { datadir = my_datadir }
let my_lbi = lbi { installDirTemplates = my_dirs }
return my_lbi
------------------------------
Message: 3
Date: Thu, 18 Dec 2014 12:50:00 -0500
From: Vale Cofer-Shabica <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Deploying a haskell application (not
a webapp)
Message-ID:
<CAAzfV4RgTkt=hWcm=pyagry0zysr_f4inuzjz5dxome3qoc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Does anyone have any experience with Halcyon[1]? It purports to do just
this.
[1] https://halcyon.sh/
--
vale cofer-shabica
<401.267.8253>
On Thu, Dec 18, 2014 at 10:39 AM, Michael Orlitzky <[email protected]>
wrote:
>
> On 12/18/2014 03:20 AM, Alan Buxton wrote:
> > Oh that's cool. Is there a way to configure this in some file so that
> when I
> > build just this application a particular datadir is used?
>
> The usual Setup.hs is just a dummy file; Cabal even ignores it. But if
> you switch to a "custom" build (from "simple") you can do some
> preprocessing in Setup.hs:
>
> https://www.haskell.org/cabal/users-guide/developing-packages.html
>
> In the section "More complex packages", it shows you how to add hooks
> that get executed before each configure/build/etc stage. If you add a
> configure hook that mangles the datadir template, you can override the
> default. Here's a Setup.hs that seems to work:
>
> -- Welcome to the jungle, baby.
> import Distribution.PackageDescription
> import Distribution.Simple
> import Distribution.Simple.Configure
> import Distribution.Simple.InstallDirs
> import Distribution.Simple.LocalBuildInfo
> import Distribution.Simple.Setup
>
> my_hooks :: UserHooks
> my_hooks = simpleUserHooks { confHook = my_conf_hook }
>
> main :: IO ()
> main = defaultMainWithHooks my_hooks
>
> my_conf_hook :: (GenericPackageDescription, HookedBuildInfo)
> -> ConfigFlags
> -> IO LocalBuildInfo
> my_conf_hook (gpd,hbi) cf = do
> lbi <- configure (gpd, hbi) cf
>
> let orig_dirs = installDirTemplates lbi
> let my_datadir = toPathTemplate "/foo/bar"
> let my_dirs = orig_dirs { datadir = my_datadir }
> let my_lbi = lbi { installDirTemplates = my_dirs }
> return my_lbi
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141218/f8d88d91/attachment-0001.html>
------------------------------
Message: 4
Date: Fri, 19 Dec 2014 02:39:21 +0100
From: Pascal Knodel <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Does/How does GHC/Haskell optimize this
('almost identical associative expressions', pattern matching
reordering)
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
Hi all,
a) I've learned that Haskell uses graphs (graph reduction) to do
optimizations / 'sharing'. Calculation example:
-- (1 + 2) + (1 + 2)
-- ~> 3 + 3
-- ~> 6
in contrast to
-- (1 + 2) + (3 + 0)
-- ~> 3 + (3 + 0)
-- ~> 3 + 3
-- ~> 6
What does it do in a case like:
... min 0 1 ... min 1 0 ...,
or: (1 + 2) + (2 + 1)
where a function definition is used which has the same result
in both cases, but arguments are flipped. This is a simple example
for a very general problem.
What does the underlying system do about it?
(a1) Can it detect and optimize it? In the example it would be easy to
reduce
it to the relations that define the min function. Is GHC able to detect
it? (a2) Is there a super language to Haskell, like an speci. assembler in
other paradigms, that could split code into even smaller pieces?
(a3) What happens at run-time, for example: ... min a b ... min b a ...?
b) About 'pattern matching': Does Haskell reorder
patterns for optimization? How/what technique does it use there? Example:
...
f [] = ...
f (a : as) = ... f ( b(a) ) ...
...
VS.
...
f (a : as) = ... f ( b(a) ) ...
f [] = ...
...
If Haskell does pattern matching like I've been told: top down, the first
definition would statistically be inefficient, because recursive
functions are
normally called with the intension to do some (recursive) calculations.
I tested (*)
it (without optimization). What do I need to know to understand this
behavior?
* Tests were (+RTS -<test> -RTS):
-------------------- snip --------------------
module Test where
f1 :: String -> String
f1 [] = []
f1 [a1] = [a1]
f1 [a1,a2] = [a1,a2]
f1 [a1,a2,a3] = [a1,a2,a3]
f1 [a1,a2,a3,a4] = [a1,a2,a3,a4]
f1 [a1,a2,a3,a4,a5] = [a1,a2,a3,a4,a5]
f1 [a1,a2,a3,a4,a5,a6] = [a1,a2,a3,a4,a5,a6]
f1 (a1 : a2 : a3 : a4 : a5 : a6 : a7 : as) = f1 as
f2 :: String -> String
f2 (a1 : a2 : a3 : a4 : a5 : a6 : a7 : as) = f2 as
f2 [a1,a2,a3,a4,a5,a6] = [a1,a2,a3,a4,a5,a6]
f2 [a1,a2,a3,a4,a5] = [a1,a2,a3,a4,a5]
f2 [a1,a2,a3,a4] = [a1,a2,a3,a4]
f2 [a1,a2,a3] = [a1,a2,a3]
f2 [a1,a2] = [a1,a2]
f2 [a1] = [a1]
f2 [] = []
p1 :: IO ()
p1 = print $ f1 [' ' | _ <-[1 .. 10^9] ] -- 63.87 secs
p2 :: IO ()
p2 = print $ f2 [' ' | _ <-[1 .. 10^9] ] -- 62.68 secs
-------------------- snip --------------------
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 78, Issue 18
*****************************************