- 2020-12-22: Monads are burritos, but today's #haskell problem brings together the whole enchilada! In today's #haskell solution we find that whole enchilada is a hot tamale! ... and also map all the air bases of an alliance.
- 2020-12-21: Collecting the airbases for all the countries of an alliance from the graph-store is today's #haskell exercise. Today's #haskell solution shows how to work with the `withArray` Aeson function.
- 2020-12-18: For today's #haskell problem, we extract an alliance, its member countries, and their capitals from the graph-store to display these data on a global-viewer, such as google Earth. For today's #haskell solution, with #KML and @neo4j, we see that this is an alliance that nearly spans the globe!
- 2020-12-16: Extracting an alliance and its member countries from a graph store is today's #haskell problem. In today's #haskell solution we find that, hm, marshalling aggregated data is more than a bit of work!
- 2020-12-15: "What is the capital of Singapore?" for today's #haskell problem. Today's #haskell solution shows that the capital of Singapore is ... well: SINGAPORE! YAY!
- 2020-12-11: For today's #haskell problem we will be adding lats and longs to country capitals in our graph-store. Capitals now have lats/longs in the graph-store.
- 2020-12-10: Today's #haskell problem is to relink capitals from aliases to source countries. Today's #haskell solution clarified the problem, then provided a data-correction-solution.
- 2020-12-09: Reassociating alliances from alias nodes to their source country nodes. Today's #haskell solution: and we update aliased-alliances-... oops! Unicode. Joy.
- 2020-12-07: For today's #haskell problem, we filter out unicode points in both countries and their aliases, ... but we also ask: is filtering the right way to go, or are unicode points being properly represented in JSON by Data.Aeson? Today's #haskell solution provides aliases to country names (... even as we add some manually ... *cough* #PleaseIgnoreTheManBehindTheCurtain)
- 2020-12-03: Today's #haskell problem: adding alias names to a country ... should be simple? BUT UNICODE! :( Today's #haskell solution: UNICODE FIXED FOR ALIASES! WOOT! ... but what about for the source countries? IM CRIE! 😭
- 2020-12-02: Yesterday, we triaged data for correction. Today #haskell problem is data correction, part I: adding `new` countries we missed before. Today's #haskell solution: o, Guinea-Bissau, be ye no longer an orphan, but be home, now, in Africa!
- 2020-12-01: Data correction. Half the problem of data-correction is to realize that you must do a data-correction. The other half of half the problem is to gather the data that needs to be corrected, along with the context of the correction: today's #haskell problem. Today's #haskell solution shows that the concept of triage is so helpful in setting up to solve data-correction problems.
Incorporates strong typing over predicate logic programming, and, conversely, incorporates predicate logic programming into strongly typed functional languages. The style of predicate logic is from Prolog; the strongly typed functional language is Haskell.
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
Curry away theprintXML xml = (\elt -> printElementWithOffset elt 0 >> return elt) (rep xml)
xml
-argument to theprintXML
-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 alliances. The 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
Givenspf :: a -> Maybe a -> Maybe b
- 2020-10-21: given:
updater :: b -> Maybe b
andfirstPass :: 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
- 2020-10-30: Today's #haskell problem is to read and to parse a wikitext file to get a comprehensive list of military alliances. Parsing wikitext of alliances of the world... WITH #haskell!
- 2020-10-28: Today's #haskell problem is to ingest military alliances of the world from http://wikidata.org as JSON. The #haskell solution: (*:)-operator and a higher-order alter-function FTW!
- 2020-10-26: The previous week we've examined wikidata for countries, continents and airbases. For today's #haskell exercise, let's memorialize our findings.* 'memorialize our findings' is a fancy-pants term for 'print statement,' ICYMI. For the #haskell solution, "We are now going to introduce some steps that are a bit more difficult... Ready. Set. And. Begin."
- 2020-10-23: Today's #haskell problem: "Unicode? What, even, is that?" ... sez Haskell, smh. Also, if you know how to get Text not to escape unicode points on output (to, say, a REST endpoint), much obliged if you told me this dark magic. Today's #haskell solution shows airbases (with their associated countries) added to the graph database.
- 2020-10-20: Next evolutionary step. We have Continents and countries as data structures. For today's #haskell problem let's find out how we can (can't?) merge in airbases with countries. Hoo, doggies! "Upload airbases to the graph database!" he said. "It'll be easy!" he said. Today's #haskell solution, if not in book-form, then in book-length!
- 2020-10-16: Map of a -> b or b -> a? ... If you're asking that question, why not Graph? Today's #haskell exercise. A mapping of continents to countries. Surprisingly, wikidata.org does not have this as data amenable to extraction.
- 2020-10-15: From continent->country mapping to country->continent mapping for today's #haskell problem. `sequence` is the secret-sauce for today's #haskell solution.
- 2020-10-14: Today's #haskell problem is to get countries by continent from a ... 'markdown' file? That is not markdown. Deal with it. Countries: meet your Continents.
- 2020-10-13: Okay. #StringsAreWrong. Everybody knows this. Wikidata: "Let's encode LongLats as strings ... IN JSON!" Please let's not. Today's #haskell exercise. The solution that produces airbases with lat/longs. REAL lat/longs, smh.
- 2020-10-12: Today's #haskell problem is airbases of the world from wikidata.org ... with some duplicates. Today's #haskell solution reads in JSON, even ... 'JSON' that encodes 'LongLat's (not lat/longs) as ... strings? Really? Yes, even points-as-strings. Remember: #StringsAreWrong ~ Richard A. O'Keefe, 26 April 1994
- 2020-10-09: Today's #haskell problem is this: Production data: "Let's see if we can make the simple act of parsing a 'JSON file' [that isn't a JSON file] impossible for the ol' el geophf!" Nice try, production data. Nice try.
Wednesday, September 2, 2020
September 2020 Haskell Problems and Solutions
- 2020-09-09: Today's #haskell exercise is to compile our book-word-net into a Haskell module. The #haskell solution compiled the August 2020 Gutenberg top 100 read books into Haskell terms.
- 2020-09-08: Data analytics on our top 100 gutenberg books is today's #haskell exercise. Did you know that there approximately 2000 English words in common usage? Today's #haskell solution: "Sounds about right."
- 2020-09-01: Today's #haskell problem is reducing a map of mapping of information to maps to a map. HOW HASKELL-Y! Yesterday's #haskell solution updated both problem and solution and made some data-discoveries along the way. Neat-o!
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.- remove
flip
to get the same functional result. - curry away
ont
from the functionremoveInfreqs
- curry away
wordcounts
from the map-lambda function. curry away
infrequentWords
from the functionremoveInfreqs
n.b.: This curry may not be as straightforward as the other curries.
- remove
2020-09-01: Given all of the above, and now that you've curried the above lambda to [SPOILER]:
Curry away\key -> const (not (Set.member key stoppers))
key
from this new lambda.
Wednesday, August 26, 2020
August 2020 1HaskellADay 1Liners
- 2020-08-31:
>>> :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) strSimple 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 manyinfo
-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
- 2020-08-31: For today's #haskell problem we learn the nature of the words "the" and "yesterday." Fundamental things. SCROOGE! Yesterday's #haskell solution shows us that "scrooge" was the most-written word in "A Christmas Carol." Fancy that!
- 2020-08-28: Today's #haskell problem: a word-frequency analysis, ... a CLEAN-word-frequency analysis. Today's #haskell solution. Amazing, isn't it, that the word Charles Dickens wrote the most, by far, was 'the'. #writerslife
- 2020-08-27: We're looking at 'weird characters' and 'weird words' for today's #haskell problem. We found words, weird words, and the weird characters in those weird words in today's #haskell solution.
- 2020-08-26: For today's #haskell problem, let's download the top-100 books from project gutenberg! For today's #haskell solution, we have the top-100 gutenberg books, downloaded and ready for analysis!
- 2020-08-25: "Project Gutenberg, here I come!" is my battle-cry for today's #Haskell problem. We have an index to book indices for yesterday's #haskell solution.
- 2020-08-24: Multiplication using cosines is called ... Prosthaphaeresis... and also called: "today's #haskell problem."
- 2020-08-21: Gimme a hint? ... or two? Today's #haskell problem is to find words in dictionaries with the help of supplied hints. "Alien." The word was "alien" for today's #Haskell solution (because it's always the aliens) (I didn't say that.) I, FOR ONE, WELCOME OUR NEW ALIEN OVERLORDS!
- 2020-08-20: Yesterday we did word-lookups from provided dictionaries. Today's #haskell problem is a little analysis (a word histogram) of those word-dictionaries.
"fromList [(1,234371)]" That, there, them's alotta words, yup. Yesterday's #haskell solution. - 2020-08-19: SKRIBBL.io! (A part of) SKRIBBL.io is the #Haskell challenge for today. And the #haskell solution, monad-style!
- 2020-08-10: HEAPS! Luv me sum HEAPS! Today's #haskell problem is to define the Heap collection and its operations.
- 2020-08-03: Today's #haskell problem is to generate random permutation of active team members. So, yeah: random permutes down low on the team members, d'#Haskell
Thursday, July 2, 2020
July 2020 1HaskellADay Problems and Solutions
- 2020-07-31: Well, that's random. Generating random numbers and sequences is today's #Haskell problem. Today's #haskell solution shows that I can (<*>) that monad, first go, without even looking it up or anything. So, yeah, I'm walking pretty tall right now.
- 2020-07-30: Kate and Shoaib are going on vacation. Commander Adama in Star Wars tells us that for today's #haskell problem, we are to "Make it so, Number one." And: there they go! Shoaib and Kate, going on a vacay, havin' fun, and type-safely, at that, because of the #haskell solution 'n stuff.
- 2020-07-29: "How many days until ...?" A date calculator for today's #haskell problem. When I say: "Compute the date," I'm not talking fig trees, here. The solution to today's #Haskell problem.
- 2020-07-28: Today's #haskell problem involves passing arguments to and verifying results from an external application. 'frankenfurters.' That's what we're trying to sum here. 'frankenfurters.' 'Fault Tolerance'? We've got that with today's #haskell solution.
- 2020-07-27: Today's #Haskell exercise makes us realize that ... "All, in all, you're just a ... nother brick in THE WALL. :/" A solution pour vous, s'il vous plaît.
- 2020-07-24: Today's #haskell problem explores the result of processed images from, in this case, Amazon's Rekognition. Today's #haskell solution: BIRDz! ... Cardinals, in fact.
- 2020-07-23: For today's #haskell problem, let's read in a JPG (o' FLAH'z!) and write it out as a TIFF ... for, you know, like: an image processing/classification exercise, at some later date. Ooh! TIFFY! TIFF saved from loaded JPEG image.
- 2020-07-22: For today's #haskell problem we extract data from JSON returned from a REST endpoint. The #haskell solution is declarative/functional-composition goodness to parse data from JSON returned from a REST endpoint.
- 2020-07-21: We ping a public API REST endpoint for today's #Haskell problem. For today's #haskell solution, simpleHttp in Network.HTTP.Conduit does the trick!
- 2020-07-20: For today's #haskell problem we read a file that contains a JSON message and parse it.
- 2020-07-17: Oops! Where has the time gone? That's today's ... I mean, YESTERDAY's, #haskell problem.
- 2020-07-16: And now, for something completely different: today's #haskell problem has us reading a file, parsing the data, and ranking the results. #haskell solution to which level is most recruit-efficient for a dark chest.
- 2020-07-15: For today's #haskell problem, we pull what we've done so far all together and compute today's pairings, given historical context.
- 2020-07-14: For today's #haskell problem, we pull what we've done so far all together and compute today's pairings, given historical context.
- 2020-07-14: For today's #Haskell problem, we look at using our historical context of pairings to answer questions for future pairings.
- 2020-07-13: Now that we've selected pairings for today, let's store those pairings into an historical context for today's #haskell problem.
- 2020-07-08: Pairing and ... 'Mobbing' (?) ... okay, really??? is our game for today's #haskell problem. A solution to the simple pairing-problem.
- 2020-07-07: For today's #haskell problem, we lay a foundation for building a team-pairing app. This day's problem addresses a History-type to provide context to the pairing-algorithm.
- 2020-07-06: For today's #haskell problem, we look at finding the spanning trees of a graph.
- 2020-07-02: Today's #haskell exercise finds us (acyclic) pathing though a simpler, yet-not-fully connected, graph.
- 2020-07-01: For today's #haskell problem we find cycles in graphs, ... MOTORcycles in graphs! AHA! AND MAKE MINE A DUCATI! ON FYE-YARRRR! 🔥 ... no ... wait ... Oh, well. #GraphTheory