Touching Grass in Boise, ID
I went to Boise for the weekend to attend my friend Jarren’s wedding. It was my first time at an American wedding, so I felt some awkwardness at first. That soon went away; Claire’s mother and the families were very warm and welcoming. We had a blast!
I stayed for Friday and Saturday. I left for the Boise airport on Sunday morning. I also want to make a note about the Smash Burger at the airport. I had a double bacon burger and it was amazing. It was fresh and juicy and just right amount of saltiness. I will remember the taste for a long time.
Other than that, I had to wait a bit for the flight back to Orange County. Sadly, there was no grass to touch at the Boise airport. Since I have been learning functional programming for the past year, I decided to write about touching grass in Haskell instead.
I
touch
somegrass
righthere
where I am.I am too lazy to walk over
there
to touch grass. I alsoshouldn't
touchpoop
. Imight
touch somebug
if they are cute. If there isnothing
to touch, that’s OK.
module Touch.Grass
import Prelude hiding (Right)
data Where = Here | There deriving (Show)
data Which = Grass | Poop | Bug deriving (Show)
data Touch = Right Where | Don't | Might deriving (Show)
data Something = Something {
which_is :: Which, where_is :: Where
} deriving (Show)
class Touchable where
touch :: Maybe Something -> Maybe Touch
instance Touchable where
touch something = do
Something{which_is, where_is} <- something
case where_is of
There -> Nothing
Here -> case which_is of
Grass -> Just $ Right Here
Poop -> Just Don't
Bug -> Just Might
data Result = Result {
it_is :: Maybe Something, touched :: Maybe Touch
} deriving (Show)
test :: IO ()
test = do
let
thing1 = Just $ Something{which_is = Grass, where_is = Here}
thing2 = Just $ Something{which_is = Grass, where_is = There}
thing3 = Just $ Something{which_is = Poop, where_is = Here}
thing4 = Just $ Something{which_is = Bug, where_is = Here}
thing5 = Nothing
print $ Result{it_is = thing1, touched = touch thing1}
print $ Result{it_is = thing2, touched = touch thing2}
print $ Result{it_is = thing3, touched = touch thing3}
print $ Result{it_is = thing4, touched = touch thing4}
print $ Result{it_is = thing5, touched = touch thing5}