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: Unicode Fanatic ? How to use? (Brent Yorgey)
2. Re: What to do next? (Henk-Jan van Tuyl)
3. Re: What to do next? (Henk-Jan van Tuyl)
4. Re: Question about define my own typeclass (Michael Orlitzky)
5. typeclass (Dennis Raddle)
6. Array/Vector like DS in haskell (Nishant)
7. What is operator :| ? (John M. Dlugosz)
8. Re: What is operator :| ? (Tony Morris)
9. Re: What is operator :| ? (Karl Voelker)
----------------------------------------------------------------------
Message: 1
Date: Thu, 27 Mar 2014 17:26:45 -0400
From: Brent Yorgey <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Unicode Fanatic ? How to use?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Have you seen
http://www.haskell.org/haskellwiki/Unicode-symbols ?
I think it answers most of your questions. In brief: the
UnicodeSyntax pragma allows various non-ASCII symbols to be used in
place of built-in Haskell syntax (such as ? in place of forall). The
base-unicode-symbols defines non-ASCII synonyms for common functions
defined in the 'base' package. The two are entirely orthogonal: the
new names for things in 'base' have nothing to do with Haskell syntax;
conversely, Haskell with no extensions already supports arbitrary
Unicode in identifier names.
-Brent
On Thu, Mar 27, 2014 at 03:51:22PM -0500, John M. Dlugosz wrote:
> I love using non-ASCII characters! Even my name, D?ugosz, needs
> Latin-2. My wife's name, ?, doesn't even use Latin characters.
> I've inserted thousands of em and en dashes in Wikipedia and can
> easily type at least three kinds of blank space.
>
> When I was in a college class on programming theory, we studied
> Backus?s FP System and I corresponded with John Backus to ask a
> question the prof couldn't handle, and he sent me the TeX definitions
> he used, so my homework really did match the appearance of the
> textbook. But that's another story. I managed to get my name in the
> Unicode 3 hardcopy book.
>
> So, I relish the ability to use proper math symbols in Haskell.
>
> Here is an example of what I've tried:
>
> {-# LANGUAGE UnicodeSyntax #-}
>
> import Prelude.Unicode
>
> f x y = x?y
>
> result = f ? id
>
> -- problem = ? True
>
> Is the UnicodeSyntax pragma a different mechanism than the modules?
> Do I need to state both, or do they clash, or work together, or what?
>
> Do I need to list all the individual modules (up to 12 of them) as
> needed (see http://hackage.haskell.org/package/base-unicode-symbols)
> or can they be brought in as one easy chunk, as the package itself is
> one thing?
>
> The compiler does not like the ? symbol, with or without the pragma.
> http://hackage.haskell.org/package/base-unicode-symbols-0.2.2.4/docs/Prelude-Unicode.html
> clearly shows it (the first one!) and it appears in the module source
> so presumably it didn't choke there. I recall seeing that it is one
> of the "problematic" symbols but GHC has some extensions.
>
> OTOH, I read that ? can?t be made to work, which is sad. Maybe ?
> (which is a symbol) can be used instead?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 2
Date: Thu, 27 Mar 2014 23:06:02 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell" <[email protected]>,
"bruce li" <[email protected]>
Subject: Re: [Haskell-beginners] What to do next?
Message-ID: <op.xdeiccs2pz0j5l@zen5>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Thu, 27 Mar 2014 16:50:28 +0100, bruce li <[email protected]> wrote:
> 2. How to write cooler code like lift2 ((++) =<<) preillion postillion?
> How could I make such usage a habit?
I think it is better to not make this a habit; such coding is both hard to
write and read. IMHO a better way to write this, is using a list
comprehension:
[x ++ y | x <- preillion, y <- postillion]
I simple cases, point-free style[0] can be an advantage, however.
Regards,
Henk-Jan van Tuyl
[0] http://www.haskell.org/haskellwiki/Pointfree
--
Folding@home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
------------------------------
Message: 3
Date: Fri, 28 Mar 2014 00:36:01 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell" <[email protected]>,
"bruce li" <[email protected]>
Subject: Re: [Haskell-beginners] What to do next?
Message-ID: <op.xdemibtlpz0j5l@zen5>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Thu, 27 Mar 2014 23:06:02 +0100, Henk-Jan van Tuyl <[email protected]>
wrote:
> On Thu, 27 Mar 2014 16:50:28 +0100, bruce li <[email protected]> wrote:
>
>> 2. How to write cooler code like lift2 ((++) =<<) preillion postillion?
>> How could I make such usage a habit?
>
> I think it is better to not make this a habit; such coding is both hard
> to write and read. IMHO a better way to write this, is using a list
> comprehension:
> [x ++ y | x <- preillion, y <- postillion]
Studying a bit better on the example, I see that I misinterpreted it; this
show how hard it is to read.
Regards,
Henk-Jan van Tuyl
--
Folding@home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
------------------------------
Message: 4
Date: Thu, 27 Mar 2014 21:10:50 -0400
From: Michael Orlitzky <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Question about define my own
typeclass
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 03/27/2014 11:28 AM, ke dou wrote:
> Hi,
>
> Sorry for the spam.
>
> I am new to Haskell.
> I want to define my own typeclass which can convert from my own types
> like MyBool, MyInt, and MyString to according Haskell types.
As you've seen, this is actually a hard problem and it needs some of
GHC's more advanced machinery.
Mateusz's solution uses FunctionalDependencies; there is a similar
extension called TypeFamilies which allow you to do many of the same
things with (IMO) a nicer syntax. You can think of TypeFamilies as
allowing you to define functions between types. And then, just like you
can define functions between values in a typeclass, you can define
functions between types. This allows you to say (in the instance
declaration) which return type goes with MyBool, MyInt, etc.
Here is a simple modification of your program (2.5 lines?) using type
families. In the type class definition, the "type Return a..." line
means that each instance declaration needs to define a type associated
'a' called 'Return a'. Then in the type signature of 'conversion', we
can use that type, solving the problem that others have pointed out.
> {-# LANGUAGE TypeFamilies #-}
>
> module Conversion where
>
> import qualified Prelude
>
> class Conversion a where
> type Return a :: *
> conversion :: a -> (Return a)
>
> data MyBool = MyTrue | MyFalse
>
> instance Conversion MyBool where
> type Return MyBool = Prelude.Bool
> conversion MyTrue = Prelude.True
> conversion MyFalse = Prelude.False
------------------------------
Message: 5
Date: Thu, 27 Mar 2014 18:35:11 -0700
From: Dennis Raddle <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: [Haskell-beginners] typeclass
Message-ID:
<cakxlvor2oby4rub8jvkmvxb7pmdq+q2yktbaahyjnsjb7np...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
If I write a function like this:
f (x1,y1) (x2,y2) = (x1++x2,y1++y2)
My understanding of typeclasses is just developing, but I notice this is a
bit like "lifting" (++) into a tuple. Maybe there is some existing
typeclass and a 2-tuple is already an instance of it? Like arrow?
D
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140327/cae76041/attachment-0001.html>
------------------------------
Message: 6
Date: Fri, 28 Mar 2014 11:00:38 +0530
From: Nishant <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Array/Vector like DS in haskell
Message-ID:
<caeqdmz5potekanqumnunzxs_wdear1hh5mfptuihao4adil...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
Can someone elaborate on how to create a DS which acts like an array or
vector and has same time complexity ?
A list though can act like array but getting value at index i is linear
time but in actual array it is constant.
Regards.
Nishant
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140328/799ca065/attachment-0001.html>
------------------------------
Message: 7
Date: Fri, 28 Mar 2014 00:54:03 -0500
From: "John M. Dlugosz" <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] What is operator :| ?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
http://www.haskell.org/haskellwiki/Typeclassopedia under ?8.1,
sconcat = sconcat (a :| as) = go a as where
What is the meaning of :| ?
I see it is really in the cited module source, not a typo on the page.
More generally, is there some effective way to search for non-alphabetical
Haskell things?
Google just ignores the "punctuation".
------------------------------
Message: 8
Date: Fri, 28 Mar 2014 16:41:26 +1000
From: Tony Morris <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] What is operator :| ?
Message-ID:
<CAJf6Usjr9_oMD8P=B2Xfsvfh3uniC7UUux3D3Jjch=qC=tl...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
It is the constructor for a non-empty list (Data.List.NonEmpty).
http://hackage.haskell.org/package/semigroups-0.12.2/docs/Data-List-NonEmpty.html
On Fri, Mar 28, 2014 at 3:54 PM, John M. Dlugosz
<[email protected]>wrote:
> http://www.haskell.org/haskellwiki/Typeclassopedia under ?8.1,
>
> sconcat = sconcat (a :| as) = go a as where
>
> What is the meaning of :| ?
> I see it is really in the cited module source, not a typo on the page.
>
> More generally, is there some effective way to search for non-alphabetical
> Haskell things? Google just ignores the "punctuation".
>
> _______________________________________________
> 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/20140328/4e59627b/attachment-0001.html>
------------------------------
Message: 9
Date: Thu, 27 Mar 2014 23:48:49 -0700
From: Karl Voelker <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] What is operator :| ?
Message-ID:
<[email protected]>
Content-Type: text/plain
On Thu, Mar 27, 2014, at 10:54 PM, John M. Dlugosz wrote:
> More generally, is there some effective way to search for
> non-alphabetical Haskell things?
> Google just ignores the "punctuation".
For that, you can use Hayoo.
http://holumbus.fh-wedel.de/hayoo/hayoo.html
-Karl
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 69, Issue 42
*****************************************