- June 17th, 2017:

f :: (a, [a]) -> [a] -> [a]

f (c, w1) w2 = c:w1 ++ w2

Define f points-free - bazzargh @bazzargh (++).uncurry(:)
- Felt there must be a nicer way to exploit symmetry of mappend.uncurry(mappend.pure) but can't find it

# 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.

## Friday, July 7, 2017

### June 2017 1HaskellADay 1Liners

## Monday, July 3, 2017

### June 2017 1HaskellADay Problems and Solutions

- June 21st, 2017: Today's #haskell problem connects to and queries a SQL database of your choosing.
- June 16th, 2017: Today's #haskell problem has us interacting with the OS environment in anticipation of SQL database queries. Today's #haskell solution uses Applicative Functors to string together values we collect from the OS environment.
- June 15th, 2017: Today's Haskell problem comes by way of @aisamanra, Mr. Lists-are-Mu-functions-in-the-function-of-Mus. Today's #haskell solution shows Lists are Mu-functors! ... now, making them instances of type-classes, however ...
- June 14th, 2017: Today's #haskell problem is brought by way of @matthieubulte: approximating solutions with Runge-Kutta. The #haskell solution shows I can (ψ, ε, k) with the best of them! AHA! ... but is it the CORRECT solution? 🙄
- June 6th, 2017: In today's #haskell problem, we go clockwise around a binary tree, because ... we've had one too many?

## Friday, June 16, 2017

### May 2017 1Liners 1HaskellADay

- May 10th, 2017:

Define (^) :: (a -> a) -> Int -> (a -> a)

The 'power'-function where f ^ 3 = f . f . f - Conor McBride @pigworker flip ((ala Endo foldMap .) . replicate)

## Wednesday, June 7, 2017

### May 2017 1HaskellADay problems and solutions

- May 25th, 2017: Today's #haskell problem looks at the interconnectedness of languages as a graph.
- May 24th, 2017: Today's #haskell problem continues the exploration of spoken language roots catalogued in @wikidata. We present the first half of the #haskell solution that allows us to parse @wikidata results with optional values.
- May 23rd, 2017: I preface today's #haskell problem with a discussion on dirty/muddled data in @wikidata then continue onto languages. Today's #haskell solution shows us, e.g.: Cornish, Welsh and Breton are in the Brythonic language family. @wikidata
- May 22nd, 2017: Today's #haskell problem looks at spoken languages catalogued in @wikidata. Today's #haskell solution shows us @wikidata has NOTHING for the count of ENGLISH-speakers! #strangebuttrue
- May 17th, 2017: The NSA called. They are wanting the solution to today's #haskell Pentagon-number problem. Now.
- May 16th, 2017: Today's #haskell problem ... and Madonna! ... want you to justify my num! We find out that ALL YOUR BASE ARE BELONG TO US in today's #haskell solution
- May 15th, 2017: Today's #haskell problem warns us: "ACHTUNG, LOOKENPEEPERS! ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN." Today's #haskell solution taught me SO MUCH German. I mean SO MUCH!
- May 10th, 2017: For today's #haskell problem: when doing egg-arithmetic, we do not things by halves! ... or, perhaps, we do! Today's #haskell solution is EGGS! EGGS AS A POWER FUNCTION! EGGS EVERYWHERE!
- May 8th, 2017: Today's #haskell problem puts us 🎶 "Back on the Hang Gangs!" 🎶 Today's #haskell solution: "We must, indeed, all hang together or, most assuredly, we shall all hang separately."
- May 5th, 2017: HAPPY #CincodeMayo ... BUT ON A TUESDAY?!? What year was that, then? Today's #haskell problem. Today's #haskell solution shows Cinco de Mayo happens EVERY YEAR?!? Who da thunk it?
- May 3rd, 2017: Today's #haskell problem: April, May, and June are three sisters, and you have to find their ages. ... #awkward. Today's #haskell solution we have the old 1, 2, 3 sisters. Not that I'm saying these sisters are old. Not me. Nope.
- May 2nd, 2017: Ah! May! When Spring is in the Air! And #haskell-ers thoughts turn to Love* *solving today's problem. Today's #haskell solution presents a conundrum: Is the solution "spring" or "spring"? Hm. Tough call!
- May 1st, 2017: Happy May Day, #haskell-ers! Today we combat the academic illness: dafundzarlow ... let that sink in. Today we see two solutions to the #haskell problem of budgeting for cake and candy at Maura's school party. And to those of you who think #haskell has no practical application? Pooh on you! BUDGETING CAKE AND CANDY AT PARTIES IS TRÈS PRACTICAL! 😡

## Wednesday, May 10, 2017

### April 2017 1HaskellADay 1Liners

- April 14th, 2017: given

eitherOr, neitherNor :: Eq a => a -> a -> a -> Bool

Is eitherOr not neitherNor?

Prove or disprove. - April 14th, 2017: given

neitherNor :: Eq a => a -> a -> a -> Bool

andNot :: Eq a => a -> a -> Bool

How do you compose neitherNor 1 0 and andNot 4? - April 11th, 2017:

opts :: Credentials -> Options

opts c = defaults & auth ?~ basicAuth (pack $ keyToken c) (pack $ secretToken c)

point-free-itize

given:

data Credentials = Credentials { keyToken, secretToken :: String }

and (?~) and (&) are from Control.Lens

Snaps for elegance

The above code from quillio/Twillo.hs by ismailmustafa

## Monday, May 1, 2017

### April 2017 1HaskellADay Problems and Solutions

- April 26th, 2017: Today we do SCIENCE! (ballistic physics, actually) with #haskell.
- April 25th, 2017: "MOM! MOM! NO BOOK!" Today's #haskell problem: help little Johnny or little Jane's mom find the book! Today's #haskell solution solves mom + mom + no == book, where k == 9 in the blink of an eye with SCIENCE!
- April 21st, 2017: Today's #haskell problem analyzes @wikidata when it has very poor data-quality and -quantity. #Alaska
- April 19th, 2017: Today's #haskell problem looks at autom(agic)ally generating a SPARQL eye-color query. Today's solution gives EyeColors reified to #haskell values from a @wikidata SPARQL query
- April 18th, 2017: Today's #haskell problem takes on the HUGE task of automating writing simple SPARQL queries. Today's #haskell solution presents a simple, well-typed @wikidata SPARQL query builder.
- April 17th, 2017: We look at US States and their Capitals as SPARQLwikidata.org query for today's #haskell problem. For today's #haskell solution we had to drill down into depth of #wikidata resulting JSON to get our State Capitals.
- April 14th, 2017: Today's #haskell problem we make our first foray (again) into the world of @wikidata. What color are your eyes? We get our results back as JSON from our wikidata.org SPARQL query for today's #haskell solution.
- April 13th, 2017: For today's #haskell problem we have a little multiplication puzzle. Today's #haskell solution is 'Prolog-escque.' What would your approach be? Oh, and function-composition with (<*>)
- April 12th, 2017: Today's #haskell problem is a little word puzzle via the Mensa Genius Quiz-a-Day Book by Dr. Abbie Salny. Today's #haskell solution finds you looking rather smart, I must say!
- April 7th, 2017: You're decorating for Spring so you need to write a constraint solver because you're in #Mensa for today's #haskell. tfw you write all these generate and test functions and replace them with a simple filter application #haskell
- April 6th, 2017: Today's #haskell problem is (kinda) based on the OS upon which all other OS's bow down before: FORTH. Fight me. And today #haskell solution we find a use for the </> operator.
- April 5th, 2017: Today's #haskell problem looks at the rise of #bitcoin prices over the past year. Today's #haskell solution runs investment scenarios over a year of historical #bitcoin price data

## Tuesday, April 11, 2017

### March 2017 1HaskellADay 1Liners

- March 30th, 2017:

divide :: (a -> Either b c) -> [a] -> ([b], [c]) This function is somewhere easy to get to, right?

via @fmapE - @fmapE: divide f = foldr (either (first . (:)) (second . (:)) . f) ([], [])
- SocialJusticeCleric @walkstherain divide f = Data.Either.partitionEithers . fmap f
- andrus @andrus divide f = foldMap $ (swap . pure . pure ||| pure . pure) . f
- matt @themattchan divide = partitionEithers ... map where ... = (.).(.)
- March 13th, 2017:

Palindromes have nothing to do with today's #haskell problem of anagrams. So what.

Define

palindrome :: String -> Bool

elegantly - SocialJusticeCleric @walkstherain all id . (zipWith (==) =<< reverse)
- SocialJusticeCleric added: TIL Data.Foldable.and
- bazzargh @bazzargh ap (==) reverse?
- March 13th, 2017:

type Bag a = Map a Int

anagram :: Ord a => [a] -> [a] -> Bool

anagram src = (== Bag.fromList src) . Bag.fromList

Redefine with <*> - Denis Stoyanov @xgrommx why not?

anagram = (==) `on` Bag.fromList

Subscribe to:
Posts (Atom)