What does left arrow <- mean outside a do block?Haskell: use of unsafePerformIO for global constant bindings

Time at 1G acceleration to travel 100 000 light years

Build a scale without computer

How can I prevent a user from copying files on another hard drive?

How to recover a single blank shot from a film camera

How do I become a better writer when I hate reading?

How to ask if I can mow my neighbor's lawn

Can a character with the Polearm Master feat make an opportunity attack against an invisible creature that enters their reach?

Can you place a web spell on a surface you cannot see?

How can the US president give an order to a civilian?

Is using Legacy mode is a bad thing to do?

Can you create a noise using Minor Illusion/Thaumaturgy on an area you cannot see?

I'm yearning in grey

How is linear momentum conserved in circular motion?

...and then she held the gun

Fantasy game inventory — Ch. 5 Automate the Boring Stuff

Using roof rails to set up hammock

How "fast" do astronomical events occur?

I wish, I yearn, for an answer to this riddle

Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)

Digital signature that is only verifiable by one specific person

How to prevent cables getting intertwined

Are there examples of rowers who also fought?

Is it a bad idea to have a pen name with only an initial for a surname?

Why we can't jump without bending our knees?



What does left arrow


Haskell: use of unsafePerformIO for global constant bindings






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








10















I came across with the following code recently and it bothers me a lot



lowerSafeForeignCall dflags block
| (entry, middle, CmmForeignCall .. ) <- blockSplit block
= do
-- do block stuffs
-- Block doesn't end in a safe foreign call:
| otherwise = return block


This piece of code is from
https://phabricator.haskell.org/rGHCb0534f78a73f972e279eed4447a5687bd6a8308e



in file compiler/cmm/CmmLayoutStack.hs



line 983



I really would like to konw what is this <- in the second line.
I believe lowerSafeForeignCall is a function and the | and 'otherwise' indicate this function uses guards. So



(entry, middle, CmmForeignCall .. ) <- blockSplit block


must be of type Bool. But the <- is outside any do block.
I did some search online but still not a single clue about this usage.










share|improve this question



















  • 3





    wiki.haskell.org/Keywords#.3C-

    – Will Ness
    May 31 at 11:02

















10















I came across with the following code recently and it bothers me a lot



lowerSafeForeignCall dflags block
| (entry, middle, CmmForeignCall .. ) <- blockSplit block
= do
-- do block stuffs
-- Block doesn't end in a safe foreign call:
| otherwise = return block


This piece of code is from
https://phabricator.haskell.org/rGHCb0534f78a73f972e279eed4447a5687bd6a8308e



in file compiler/cmm/CmmLayoutStack.hs



line 983



I really would like to konw what is this <- in the second line.
I believe lowerSafeForeignCall is a function and the | and 'otherwise' indicate this function uses guards. So



(entry, middle, CmmForeignCall .. ) <- blockSplit block


must be of type Bool. But the <- is outside any do block.
I did some search online but still not a single clue about this usage.










share|improve this question



















  • 3





    wiki.haskell.org/Keywords#.3C-

    – Will Ness
    May 31 at 11:02













10












10








10


1






I came across with the following code recently and it bothers me a lot



lowerSafeForeignCall dflags block
| (entry, middle, CmmForeignCall .. ) <- blockSplit block
= do
-- do block stuffs
-- Block doesn't end in a safe foreign call:
| otherwise = return block


This piece of code is from
https://phabricator.haskell.org/rGHCb0534f78a73f972e279eed4447a5687bd6a8308e



in file compiler/cmm/CmmLayoutStack.hs



line 983



I really would like to konw what is this <- in the second line.
I believe lowerSafeForeignCall is a function and the | and 'otherwise' indicate this function uses guards. So



(entry, middle, CmmForeignCall .. ) <- blockSplit block


must be of type Bool. But the <- is outside any do block.
I did some search online but still not a single clue about this usage.










share|improve this question
















I came across with the following code recently and it bothers me a lot



lowerSafeForeignCall dflags block
| (entry, middle, CmmForeignCall .. ) <- blockSplit block
= do
-- do block stuffs
-- Block doesn't end in a safe foreign call:
| otherwise = return block


This piece of code is from
https://phabricator.haskell.org/rGHCb0534f78a73f972e279eed4447a5687bd6a8308e



in file compiler/cmm/CmmLayoutStack.hs



line 983



I really would like to konw what is this <- in the second line.
I believe lowerSafeForeignCall is a function and the | and 'otherwise' indicate this function uses guards. So



(entry, middle, CmmForeignCall .. ) <- blockSplit block


must be of type Bool. But the <- is outside any do block.
I did some search online but still not a single clue about this usage.







haskell ghc guard-clause pattern-guards






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 31 at 11:06









Will Ness

48.3k470131




48.3k470131










asked May 31 at 10:36









TheodoraTheodora

9416




9416







  • 3





    wiki.haskell.org/Keywords#.3C-

    – Will Ness
    May 31 at 11:02












  • 3





    wiki.haskell.org/Keywords#.3C-

    – Will Ness
    May 31 at 11:02







3




3





wiki.haskell.org/Keywords#.3C-

– Will Ness
May 31 at 11:02





wiki.haskell.org/Keywords#.3C-

– Will Ness
May 31 at 11:02












2 Answers
2






active

oldest

votes


















11














That's a pattern guard:




guard       →   pat <- infixexp      (pattern guard)




[...]




A guard has one of the following forms:




  • pattern guards are of the form p <- e, where p is a pattern (see Section 3.17) of type t and e is an expression type t. They succeed if the expression e matches the pattern p, and introduce the bindings of the pattern to the environment.



Where normal guards are limited to a boolean check, pattern guards can match against an arbitrary pattern and define local variables. (In your case entry, middle, and the contents of CmmForeignCall will be directly available in the function body.)



You can think of boolean guards as equivalent to pattern guards with a pattern of True:



| expr


works like



| True <- expr





share|improve this answer






























    8














    This is a pattern guard [Haskell-wiki]. Since Haskell'10 a guard is a list of qualifiers. A qualifier can be a condition (like in the old guards), and pattern guards.



    Haskell will thus (lazily) evaluate the expression on the right side of the arrow <- and aim to match it with the pattern on the left of the arrow. If that succeeds, than the guard (well that part of the guard) is successful. If all the parts of the guard are successful, then the rule "fires".



    In this specific case the only part of the pattern that might fail is the fact that the third item of the 3-tuple is not a CmmForeignCall data constructor. Furthermore by using this pattern guard, we can of course use entry, middle in the body of the expression.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56393471%2fwhat-does-left-arrow-mean-outside-a-do-block%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      11














      That's a pattern guard:




      guard       →   pat <- infixexp      (pattern guard)




      [...]




      A guard has one of the following forms:




      • pattern guards are of the form p <- e, where p is a pattern (see Section 3.17) of type t and e is an expression type t. They succeed if the expression e matches the pattern p, and introduce the bindings of the pattern to the environment.



      Where normal guards are limited to a boolean check, pattern guards can match against an arbitrary pattern and define local variables. (In your case entry, middle, and the contents of CmmForeignCall will be directly available in the function body.)



      You can think of boolean guards as equivalent to pattern guards with a pattern of True:



      | expr


      works like



      | True <- expr





      share|improve this answer



























        11














        That's a pattern guard:




        guard       →   pat <- infixexp      (pattern guard)




        [...]




        A guard has one of the following forms:




        • pattern guards are of the form p <- e, where p is a pattern (see Section 3.17) of type t and e is an expression type t. They succeed if the expression e matches the pattern p, and introduce the bindings of the pattern to the environment.



        Where normal guards are limited to a boolean check, pattern guards can match against an arbitrary pattern and define local variables. (In your case entry, middle, and the contents of CmmForeignCall will be directly available in the function body.)



        You can think of boolean guards as equivalent to pattern guards with a pattern of True:



        | expr


        works like



        | True <- expr





        share|improve this answer

























          11












          11








          11







          That's a pattern guard:




          guard       →   pat <- infixexp      (pattern guard)




          [...]




          A guard has one of the following forms:




          • pattern guards are of the form p <- e, where p is a pattern (see Section 3.17) of type t and e is an expression type t. They succeed if the expression e matches the pattern p, and introduce the bindings of the pattern to the environment.



          Where normal guards are limited to a boolean check, pattern guards can match against an arbitrary pattern and define local variables. (In your case entry, middle, and the contents of CmmForeignCall will be directly available in the function body.)



          You can think of boolean guards as equivalent to pattern guards with a pattern of True:



          | expr


          works like



          | True <- expr





          share|improve this answer













          That's a pattern guard:




          guard       →   pat <- infixexp      (pattern guard)




          [...]




          A guard has one of the following forms:




          • pattern guards are of the form p <- e, where p is a pattern (see Section 3.17) of type t and e is an expression type t. They succeed if the expression e matches the pattern p, and introduce the bindings of the pattern to the environment.



          Where normal guards are limited to a boolean check, pattern guards can match against an arbitrary pattern and define local variables. (In your case entry, middle, and the contents of CmmForeignCall will be directly available in the function body.)



          You can think of boolean guards as equivalent to pattern guards with a pattern of True:



          | expr


          works like



          | True <- expr






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 31 at 10:41









          melpomenemelpomene

          67.8k55196




          67.8k55196























              8














              This is a pattern guard [Haskell-wiki]. Since Haskell'10 a guard is a list of qualifiers. A qualifier can be a condition (like in the old guards), and pattern guards.



              Haskell will thus (lazily) evaluate the expression on the right side of the arrow <- and aim to match it with the pattern on the left of the arrow. If that succeeds, than the guard (well that part of the guard) is successful. If all the parts of the guard are successful, then the rule "fires".



              In this specific case the only part of the pattern that might fail is the fact that the third item of the 3-tuple is not a CmmForeignCall data constructor. Furthermore by using this pattern guard, we can of course use entry, middle in the body of the expression.






              share|improve this answer



























                8














                This is a pattern guard [Haskell-wiki]. Since Haskell'10 a guard is a list of qualifiers. A qualifier can be a condition (like in the old guards), and pattern guards.



                Haskell will thus (lazily) evaluate the expression on the right side of the arrow <- and aim to match it with the pattern on the left of the arrow. If that succeeds, than the guard (well that part of the guard) is successful. If all the parts of the guard are successful, then the rule "fires".



                In this specific case the only part of the pattern that might fail is the fact that the third item of the 3-tuple is not a CmmForeignCall data constructor. Furthermore by using this pattern guard, we can of course use entry, middle in the body of the expression.






                share|improve this answer

























                  8












                  8








                  8







                  This is a pattern guard [Haskell-wiki]. Since Haskell'10 a guard is a list of qualifiers. A qualifier can be a condition (like in the old guards), and pattern guards.



                  Haskell will thus (lazily) evaluate the expression on the right side of the arrow <- and aim to match it with the pattern on the left of the arrow. If that succeeds, than the guard (well that part of the guard) is successful. If all the parts of the guard are successful, then the rule "fires".



                  In this specific case the only part of the pattern that might fail is the fact that the third item of the 3-tuple is not a CmmForeignCall data constructor. Furthermore by using this pattern guard, we can of course use entry, middle in the body of the expression.






                  share|improve this answer













                  This is a pattern guard [Haskell-wiki]. Since Haskell'10 a guard is a list of qualifiers. A qualifier can be a condition (like in the old guards), and pattern guards.



                  Haskell will thus (lazily) evaluate the expression on the right side of the arrow <- and aim to match it with the pattern on the left of the arrow. If that succeeds, than the guard (well that part of the guard) is successful. If all the parts of the guard are successful, then the rule "fires".



                  In this specific case the only part of the pattern that might fail is the fact that the third item of the 3-tuple is not a CmmForeignCall data constructor. Furthermore by using this pattern guard, we can of course use entry, middle in the body of the expression.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 31 at 10:40









                  Willem Van OnsemWillem Van Onsem

                  163k17165254




                  163k17165254



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56393471%2fwhat-does-left-arrow-mean-outside-a-do-block%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                      What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                      Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos