Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  How to include {-# LANGUAGE LambdaCase #-} at    the ghci
      prompt (Galaxy Being)
   2. Re:  How to include {-# LANGUAGE LambdaCase #-} at the ghci
      prompt (Francesco Ariis)
   3. Re:  How to include {-# LANGUAGE LambdaCase #-} at the ghci
      prompt (Galaxy Being)
   4.  Closure: exact wording (Galaxy Being)


----------------------------------------------------------------------

Message: 1
Date: Fri, 26 Mar 2021 12:20:55 -0500
From: Galaxy Being <borg...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] How to include {-# LANGUAGE LambdaCase
        #-} at  the ghci prompt
Message-ID:
        <CAFAhFSXg=q4EVK1u+bE0WpkT==dzao2gfy7q-k8mfmhr6hz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I've got this code I've entered into the ghci by hand between :{ and :}

:{
{-# LANGUAGE LambdaCase #-}
data List a = Empty | Cons a (List a) deriving (Eq, Ord, Show)
infixr 5 `Cons`

subst_c :: (a -> Bool)  -> (a, MyList a) -> MyList a
subst_c pred = \ case
                     (_, Empty)    -> Empty
                     (n, Cons e t)
                       | pred e    -> Cons n $ subst_c pred (n, t)
                       | otherwise -> Cons e $ subst_c pred (n, t)
:}

but I keep getting the error

Illegal lambda-case (use -XLambdaCase)

This works fine inside an .hs file and :load and run at the prompt.
However, I'm using Emacs org-mode and need to keep everything limited to a
version of hand-entered :{ ... :}. Any suggestions?

LB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20210326/1fc0b93c/attachment-0001.html>

------------------------------

Message: 2
Date: Fri, 26 Mar 2021 18:31:53 +0100
From: Francesco Ariis <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] How to include {-# LANGUAGE
        LambdaCase #-} at the ghci prompt
Message-ID: <20210326173152.GA9876@extensa>
Content-Type: text/plain; charset=utf-8

Il 26 marzo 2021 alle 12:20 Galaxy Being ha scritto:
> I've got this code I've entered into the ghci by hand between :{ and :}
> 
> :{
> {-# LANGUAGE LambdaCase #-}
> data List a = Empty | Cons a (List a) deriving (Eq, Ord, Show)
> infixr 5 `Cons`
> 
> subst_c :: (a -> Bool)  -> (a, MyList a) -> MyList a
> subst_c pred = \ case
>                      (_, Empty)    -> Empty
>                      (n, Cons e t)
>                        | pred e    -> Cons n $ subst_c pred (n, t)
>                        | otherwise -> Cons e $ subst_c pred (n, t)
> :}
> 

    λ> :set -XLambdaCase


------------------------------

Message: 3
Date: Fri, 26 Mar 2021 16:17:19 -0500
From: Galaxy Being <borg...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] How to include {-# LANGUAGE
        LambdaCase #-} at the ghci prompt
Message-ID:
        <cafahfsupblaloic-xxcvbdfo_czc5cazq1pqyodkp5pgchu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Exactly. Thanks.

On Fri, Mar 26, 2021 at 12:33 PM Francesco Ariis <fa...@ariis.it> wrote:

> Il 26 marzo 2021 alle 12:20 Galaxy Being ha scritto:
> > I've got this code I've entered into the ghci by hand between :{ and :}
> >
> > :{
> > {-# LANGUAGE LambdaCase #-}
> > data List a = Empty | Cons a (List a) deriving (Eq, Ord, Show)
> > infixr 5 `Cons`
> >
> > subst_c :: (a -> Bool)  -> (a, MyList a) -> MyList a
> > subst_c pred = \ case
> >                      (_, Empty)    -> Empty
> >                      (n, Cons e t)
> >                        | pred e    -> Cons n $ subst_c pred (n, t)
> >                        | otherwise -> Cons e $ subst_c pred (n, t)
> > :}
> >
>
>     λ> :set -XLambdaCase
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20210326/4003fd03/attachment-0001.html>

------------------------------

Message: 4
Date: Fri, 26 Mar 2021 16:32:01 -0500
From: Galaxy Being <borg...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Closure: exact wording
Message-ID:
        <CAFAhFSWXUBhncwiOQrGZF5=eaz5rfns_hyc1mdyyegrptap...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I've got this

addTwo x y = x + y
aT5 = addTwo 5
> aT5 3
8

Is it right to say aT5 is a closure over 5, or a closure over addTwo 5?

LB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20210326/cd2c6472/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 152, Issue 9
*****************************************

Reply via email to