- 2021-04-07, Wednesday:

you have`(Maybe a, Maybe b)`

you want`Maybe (a, b)`

If either (Maybe a) or (Maybe b) is

`Nothing`

then the answer is`Nothing`

.If both (Maybe a) and (Maybe b) are (Just ...)

then the answer is`Just (a, b)`

WHAT SAY YOU?

- Jérôme Avoustin @JeromeAvoustin:
`bisequence`

- p h z @phaazon_ with base:
`uncurry $ liftA2 (,)`

- greg nwosu @buddhistfist:
`(,) <$> ma <*> mb`

- Jérôme Avoustin @JeromeAvoustin:

# Typed Logic

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, April 6, 2021

### April 2021 1HaskellADay 1Liners Problems and Solutions

## Thursday, April 1, 2021

### April 2021 1HaskellADay Problems and Solutions

- 2021-04-09: We get all officious, ... sry: 'OFFICIAL' ... with today's #haskell problem. Today's #haskell solution shows us that you haven't met real evil until your TPS-report cover letter is ... Lorem Ipsum.
- 2021-04-08, Thursday: In today's #haskell problem we optionally parse a string into some value of some type. Some how. Today's #haskell solution shows us the sum of the numbers in the string was 42 (... no, it wasn't).
- 2021-04-07, Wednesday: decode vs. eitherDecode from Data.Aeson is today's #haskell exercise. In today's #haskell solution we find that it's nice when eitherDecode tells you why it failed to parse JSON.
- 2021-04-05, Monday: Today's #haskell exercise is to make a vector that is Foldable and Traversable. Today's #haskell solution gives us Vectors as Foldable and Traversable. YUS!
- 2021-04-01, Holy Thursday: In today's #haskell exercise we learn the WHOPR beat the Big Mac. We also learn how to make a safe call to an HTTPS endpoint, but that's not important as the WHOPR beating the Big Mac. "Would you like to play a game?" Today's #haskell solution says: "Yes, (safely, please)."

## Tuesday, March 23, 2021

### March 2021 1HaskellADay 1Liners

- 2021-03-23:
You have

`[a]`

and`(a -> IO b)`

.You want

`IO [(a, b)]`

That is, you want to pair your inputs to their outputs for further processing in the IO-domain.

- Chris Martin @chris__martin:
`\as f -> traverse @ [] @ IO (\a -> f a >>= \b ->`

`return (a, b)) as`

- cλementd Children crossing @clementd:
`traverse (sequenceA . id &&& f)`

(actually,

`tranverse (sequence . (id &&& f))`

)Or

`p traverse (traverse f . dup)`

- Chris Martin @chris__martin:
- 2021-03-23: You have
`[([a], [b])]`

You want

`([a], [b])`

so:

`[([1,2], ["hi"]), ([3,4], ["bye"])]`

becomes

`([1,2,3,4],["hi","bye"])`

- karakfa @karakfa:
`conc xs = (concatMap fst xs, concatMap snd xs)`

- karakfa @karakfa:

## Monday, March 1, 2021

### March 2021 1HaskellADay Problems and Solutions

- 2021-03-31, Wednesday: Let's go on 50 last dates for today's #haskell problem. Today's #haskell solution shows us the fifty last dates were the fifty best dates.
- 2021-03-30, Tuesday: Directorizin' ... WITH STYLE! ... is today's #haskell problem. Today's #haskell solution: BEHOLD THE MIGHTY POWER OF THE <*>!
- 2021-03-29, Monday: Today's #haskell problem tackles plurality and connectives to list the contents of our Fruits Basket. Today's #haskell solution gives us fruits, in the basket, properly-speaking, thanks to George Boole.
- 2021-03-25, Thursday: Today's #haskell problem has me FORTHing AT THE MOUTH! ... AGAIN! ... no, ... wait ...
- 2021-03-23, Tuesday: Let's go FORTH! and conquer! for today's #haskell problem. Today's #haskell solution gives us a little FORTHer to go FORTH and FORTH! ... and also demonstrates Gauss' sum formula ... IN FORTH! ... which is nice.
- 2021-03-22, Monday: Fixing-up and validating a JSON-as-string (and don't get me started) is today's #haskell problem. Today's #haskell solution uses Data.Aeson to transform some JSON, ... typefully.
- 2021-03-19: pi. Not pie. Not tau. pi... you know, or: close enough, is served as today's #haskell problem (via @AnecdotesMaths). PI! for today's #haskell solution. And a pie recipe from Sumeria, if you're in a baking-mood.
- 2021-03-18: Today's #haskell problem is to update lookup tables with new values. Today's #haskell solution gets the indices for foo, bar, quux, and ... Joe??? Okay.
- 2021-03-16: Today's #haskell problem uses natural language processing to consolidate words in the cloud. et, voilà: Grace Hopper wikipedia entry word-cloud, trimmed and stemmed, for today's #haskell solution.
- 2021-03-15: Today's #haskell problem explores Grace Hopper's wikipedia entry as a word-cloud generated by d3js.org for #WomensHistoryMonth Today's #haskell solution removed some obvious things (punctuation and citations) to simplify Grace Hopper's word-cloud. #WomenHistoryMonth
- 2021-03-11: It's not every Tom, Dick, and Harry that can do today's #haskell exercise... In today's #haskell solution you want an id? YOU GOT AN ID! 😤
- 2021-03-09: Let's query a directory and do something with each file in that directory for today's #haskell problem. Today's #haskell solution? THAT WAS EASY! ... so! What are we doing tomorrow? 😃
- 2021-03-05: Today we're shell-scripting ... WITH HASKELL! 😤 Today's #haskell solution says: "Well, hello there, good lookin'!"
- 2021-03-04: Today's #haskell problem: you have a time-series of values, not necessary gapless, get the latest value; then, get 'yesterday's' value. Today's #haskell solution gives us some useful functions to navigate a time-series of values.
- 2021-03-03: Today's #haskell problem asks: "Where in the world are these wineries?" Then answers that question. Ooh! Wineries! Wineries all over the globe! is in today's #haskell solution.
- 2021-03-02: For today's #haskell problem, let's add approved matched data to wineries in the graph-store. The #haskell solution! ... with a pic!
- 2021-03-01: Today's #haskell problem approves matched wineries for (eventual) storage. We approve wiki-to-graph winery metaphone matches for today's #haskell solution.

## Monday, February 1, 2021

### February 2021 1HaskellADay Problems and Solutions

- 2021-02-26: Today's #haskell problem we will be matching the metaphone'd-wineries from wikidata and from the graph-store. Today's #haskell solution gave us 16 good matches from 30 candidates.
- 2021-02-25: For today's #haskell problem we load the wineries' metaphones to the graph-store. Today's #haskell solution: MWA-HAHA! I HAVE METAPHONES FOR WINERIES!
- 2021-02-24: "What's today's date?" is today's #haskell problem. For today's #haskell solution, I think I found the successor to "Hello, world!"
- 2021-02-23: Today's #haskell exercise involves calling an external process with a winery and reading the double-metaphone encoded result. Today's #haskell solution tied our wiki- and graph-winery data to an external name-categorizing app.
- 2021-02-22: We now have a graph-store of wines, wineries, and wine-reviews, and wikidata, too! One Direction (no, not the boy-band) we can go is to merge the wikidata to our knowledge base. Project! Today's #haskell solution: (graph) wineries and (wikidata) wineries.
- 2021-02-19: Okay, we have our ~120k wine-reviews uploaded to a graph-store, great! Did we do it correctly? Hm. Today's Haskell problem. Today's #haskell solution asks: "Duplicate wine reviews? What duplicate wine reviews? Blink, blink."
- 2021-02-18: Adding prices and scores to the unicoded wine-reviews in the graph-store is today's #haskell problem. Boom! Today's #haskell solution gives us prices, scores, and wine-reviews now in the graph-store.
- 2021-02-17: Today's #haskell problem is yesterday's Haskell problem: saving out a CSV-file, but this time, we're going to save the unicode points: 'good'! Today's #haskell solution: Yay! Properly encoded unicode!
- 2021-02-16: Today's #haskell problem is to correct unicoded wine-reviews, then to save them in a CSV file for eventual upload to a graph-store. For today's #haskell solution, we came, we saw, we saved CSV, ... unicode points not quite properly encoded.
- 2021-02-15: Today's #haskell problem looks for errors in the wine-reviews JSON file which makes it invalid. Today's #haskell solution fixes JSON with a custom-build scanner.
- 2021-02-12: Today's #haskell problem: unicode, properly encoded for Text. Imagine that. Today's #haskell solution SOLVES the unicoding-problem ... except that it doesn't. :/
- 2021-02-08: In today's #haskell problem we tackle wading through wine-reviews to upload to the graph-store. Today's #haskell solution: we are able to upload some (1600+) wine-reviews so far.
- 2021-02-05: Now that we've identified duplicates in our wine graph-store, today's #haskell problem is to eliminate duplicates. In today's #haskell solution we removed duplicate wine-labels and verified no duplicate wineries, as well.
- 2021-02-04: For today's #haskell problem with look at data duplication in the graph-store (particularly: duplicated wine-labels). Today's #haskell solution shows which wines are duplicates (and triplicates, and ... megalons?)
- 2021-02-03: Today's #haskell problem looks at adding wine reviews (with some optional data) to the graph-store. Today's #haskell solution we uploaded a (very (very)) small subset of wine-reviews, prices and ratings to the graph-store.
- 2021-02-02: Enhancing graph-store data. From the @kaggle wine-taster data-set, let's extract and add the twitter handles of those who have them. Today's #haskell solution adds the wine-reviewers' twitter handles to the graph-store.
- 2021-02-01: Today's #haskell problem: counting 'dupe?' rows in a CSV file over HTTPS. Today's #haskell solution ponders: what is that 'dupe?' column for, anyway?

## Thursday, January 21, 2021

### January 2021 1HaskellADay 1Liners

- 2021-01-28: Opposite problem:

You have: [(a, Set b)]

you want: [(a, b)]

e.g.: [("hi", fromList [1,2,3]), ("bye", fromList [4,6,7]) ->

[("hi",1),("hi",2),("hi",3),("bye",4),("bye",6),("bye",7)]

Interestingly, Set is not a Monad. wut. How do you get around that problem? - D Oisín Kidney @oisdk (>>= traverse toList)
- mine: concatMap (sequence . second Set.toList)
- 2021-01-28:

We have [(Set a, b)]

we want [(a, b)]

where each element of Set a is paired with b, e.g.:

[(fromList [1,2,3], 'a'), (fromList [4,5,6], 'b')]

becomes

[(1,'a'),(2,'a'),(3,'a'),(4,'b'),(5,'b'),(6,'b')] - Steve "wash your hands" Trout @strout:

concatMap (uncurry (liftA2 (,)) . bimap toList pure) - insatiable mask wearer @tim_1729

[(a,b) | (s,b) <- xs, a <- (toList s)] - Today, 2021/01/21, is:
- Can be written with only 3 digits, What other dates can be so written? Also:
- a day where the month and day are NOT amalgamation the year. But which dates are amalgamations?

## Wednesday, January 20, 2021

### January 2021 1HaskellADay Problems and Solutions

- 2021-01-29: Ambitious! Let's upload some indexed wineries with geo-locations to the graph-store for today's #haskell problem! For today's #haskell solution we added geo-locations and wikidata QNames for some wineries, with shout-outs to @oisdk and @tim_1729, incorporating their #1Liner answers into the solution.
- 2021-01-27: We continue updating our wine-graph with wikidata. Today we update countries in the graph with wikidata QName values. Today's #haskell solution corrects the names of the countries and adds their wikidata QNames, or, put another way: O? Canada?!? NANI???
- 2021-01-26: For today's #haskell problem we compare neo4j graph data to wikidata for wineries now, and what is the "No Country"? And how do I get citizenship there?
- 2021-01-25: Okay, looking at countries aliased between wikidata and a neo4j graph for today's #haskell problem. Today's #haskell solution loads then uses a graph to resolve aliased country names.
- 2021-01-22: Today's #haskell problem: we inject countries of wineries extracted from @wikidata into the mix to ... simplify (?) things? ... wait? There're countries mismatched, too? How ... surprising. 🙄 Today's #haskell solution shows us that wine is "No Country" for old men. ... wait ... wut?
- 2021-01-21: Today's #haskell problem is to compare wineries from @wikidata to those in a @neo4j graph. Also. Did you know that there's a winery in Oregon named "Sweet Cheeks"? Now you do. You're welcome. Today's #haskell solution shows that 125 wineries match, more than 400 don't. Lots of aliasing work ahead of us.
- 2021-01-20: Today's #haskell problem asks you to parse wineries and their geo-locations from a JSON file. Simple problem; simple solution. Also: wine a bit. It helps.

Subscribe to:
Posts (Atom)