Tuesday, December 1, 2020

December 2020 1HaskellADay Problems and Solutions

Friday, November 13, 2020

November 2020 1HaskellADay 1Liner problems and solutions

  •  In my Data.XHTML library

    printXML xml = (\elt -> printElementWithOffset elt 0 >> return elt) (rep xml)

    Curry away the xml-argument to the printXML-function 

Tuesday, November 3, 2020

November 2020 Haskell Problems and Solutions

  • 2020-11-27: Is the morse code table generated from a graph better than by-hand? In today's #haskell problem, WE FIND OUT! 😤  Today's #haskell solution shows I did code the morse table by hand correctly! *whew* and also show how to extract data from a graph-store. And! has Konami's super-secret cheat-code! ^^vv<><>ba (shh! Don't tell anyone!) 

  • 2020-11-25: 'Lorem Ipsum' never looked so good ... IN MORSE CODE! :< Today's #haskell problem. Today's #haskell solution shows that Cicero had words. Yes, he did.  


  • 2020-11-23: Today's #haskell problem: ALLIANCES o' the WORLD! UNITE! (like Wonder Twin powers). As today IS Tuesday, it IS Belgium! Displaying the countries of NATO. 

  • 2020-11-20: If today WERE Tuesday, it would be ... Belgium. Today is Friday, however. (whispered: but it's still Belgium). Today's #haskell problem: render a country's air-power as KML to display on earth.google.com, or some such-like.  Today is Friday, so this must be ... Bruxelles! ... I'll allow it. Today's #Haskell solution maps Brussels and all the air bases of Belgium. 


  • 2020-11-18: As yesterday's problem of enhancing countries with additional information was SO EASY 🙄 for today's #haskell we'll take what we learned yesterday and enhance our stored continents with wikidata.org information. I'll let the band Toto explain today's #Haskell solution. "I BLESSED THE QID IN AAAAAAFRICA!" 🎵🎶 Thanks, fellahs. 🙄😎  

  • 2020-11-17: We find out capitals of ... um: 'thingies' (?) from wikidata.org for today's #haskell problem. Belgium has a wikidata.org q-id; captured in our knowledge graph. Belgium has a capital, too: Brussels, along with a lat/long coordinate; also captured. Today's #haskell solution was to map all q-id's and capitals to countries of the world

  • 2020-11-13: Today's #haskell problem? We convert our alliances and airbases graph into XML (specifically, KML). Why? you ask? BECAUSE WE CAN! ... and to get ready for ... this: #geodesicmapping Today's #haskell solution is our first two folders in KML. I'M SO PROUD OF YOU! ... hey! I can see my house from here!  
     


  • 2020-11-12: How big is our unicode-... dare I call it a 'problem'? It's not a 'problem,' but it's stopping us from talking with the REST endpoint successfully. So, today's #haskell problem is: how many non-ASCII unicode points do we have in our Alliances? You want alliances-as-a-graph? You got alliances-as-a-graph!  

  • 2020-11-11: For today's #haskell problem we attempt to upload our alliances to our Continent/Country/Airbase graph. HOW WILL THIS ATTEMPT TURN't OUT? The suspense. It's killing me. IT TURN't OUT BAD! IT TURN't OUT BAD! Bad unicode! Bad! le sigh. Today's #haskell solution (which was for yesterday's problem) leads to tomorrow's (today's, actually) Haskell problem. So it goes. 
  • 2020-11-10: The BIG KAHUNA: the military alliances of the world, derived from both wikidata and wikitext. Bringing it all together with the Organization of American States is today's #haskell problem. #BigKahuna Today's #haskell solution: and here we ... [wait for it] ... go
  • 2020-11-09: In today's #haskell exercise, we add the United Nations to the AllianceMap. Today's #haskell solution adds the United Nations to the map of world military alliances. 
  • 2020-11-06: For today's #haskell problem we add the European Union to the list of military alliances. Today's #haskell solution: European Union from wikidata.org JSON, GET! 
  • 2020-11-05: Today's #haskell problem: rolling in missing alliances and aliases (and implementing alias-parsing). 42. That's the number of alliances today's #haskell solution collected from wikitext. Coincidence? I THINK NOT! #DeepThought 
  • 2020-11-04: "We have work to do!" el geophf declares. And so, the #haskell work: missing alliancesThe good news is that there's bad news: today's #haskell solution shows that we've missed 35 alliances in our parsing. 
  • 2020-11-03: Today's #haskell problem: I give you a new, funky parser for new, funky alliances! ... and who was it who said that Haskell is no fun? We refine our parsed results, by hand-parsing missed results for today's #haskell solution. 

Wednesday, October 21, 2020

October 2020 Haskell 1-Liners

  • 2020-10-21: Curry `key` from
    secondPassFilter :: Ord a => a -> Set a -> Maybe b
    secondPassFilter key = spf key . Set.lookupGE key

    Given spf :: a -> Maybe a -> Maybe b
  • 2020-10-21: given: updater :: b -> Maybe b
    and firstPass :: Ord a => Map a b -> Map a b
    firstPass m = foldr (Map.update updater) m (Map.keys m)
    #Curry away `m` from the firstPass-function
    • Social Justice Cleric @noaheasterly
      firstPass = foldr (Map.update updater) <*> Map.keys
  • 2020-10-20: all (\c -> any (`isPrefixOf` c) setb) notinb
    #Curry away the `c` lambda argument.

Friday, October 9, 2020

October 2020 1HaskellADay Problems and Solutions

Wednesday, September 2, 2020

September 2020 Haskell Problems and Solutions

Tuesday, September 1, 2020

February 2019 Haskell 1-liners

 

  • February 18th, 2019:
    Define ext :: (Maybe a, b) -> Maybe (a,b)
    e.g.: ext (Just 5, "Hi") = Just (5, "Hi")
    • Al͜l ̸͑ha͂͟il̶! @TechnoEmpress \o/ 
    • cλementd @clementd `fmap swap. sequenceA . swap` :-)
    • Raveline @Raveline bisequence . second pure
    • Alexey Radkov @sheshanaag uncurry (flip $ fmap . flip (,))
    • a fool @fresheyeball ext = \case (Just x, y) -> Just (x, y); _ -> Nothing

September 2020 Haskell 1-liners

  • 2020-09-08: given

    removeInfreqs :: Set String -> Ontology -> Ontology
    removeInfreqs infrequentWords ont = 
       Map.map (\wordcounts -> foldl (flip ri') wordcounts infrequentWords) ont

    where Ontology is a map-of-maps.

    1. remove flip to get the same functional result.
    2. curry away ont from the function removeInfreqs
    3. curry away wordcounts from the map-lambda function.
    4. curry away infrequentWords from the function removeInfreqs

      n.b.: This curry may not be as straightforward as the other curries.

  • 2020-09-01: Given all of the above, and now that you've curried the above lambda to [SPOILER]:

    \key -> const (not (Set.member key stoppers))

    Curry away key from this new lambda.

Wednesday, August 26, 2020

August 2020 1HaskellADay 1Liners

  • 2020-08-31:

    #Haskell #BetterWithCurry #1Liner For:
    >>> :t Map.filterWithKey 
    Map.filterWithKey :: (k -> a -> Bool) -> Map k a -> Map k a

    we have this filtering function: \key _val -> not (Set.member key stoppers)

    _val is unused. Curry it away.

  • 2020-08-28: 
    rmFront :: Set Char -> String -> String
    rmFront weirds str = dropWhile (flip Set.member weirds) str
    Simple currying questions: can this function-implementation be simplified with currying? Can it be simplified ... MORE? Answers: yes, and yes. Show your implementation.

  • 2020-08-26: We have this: \info -> importBook info >>= return . (info,) There are way too many info-references. What's a better way to write this expression?
    • Five solutions from @noaheasterly:
      • runKleisli (id &&& Kleisli importBook)
      • liftA2 (liftA2 (,)) return importBook
      • liftA2 (fmap . (,)) id importBook
      • traverse importBook . join (,)
      • traverse importBook . (id &&& id)

Monday, August 3, 2020

August 2020 1HaskellADay Problems and Solutions

Thursday, July 2, 2020

July 2020 1HaskellADay Problems and Solutions


June 2020 1HaskellADay Problems and Solutions

  • YAY! HELLO! Our first #haskell exercise in a while!... and this exercise is about ... wait for it ... exercise
  • For today's #haskell exercise we convert a set of arcs to a graph. #GraphTheory