Let me guess there is a data PL as a sum type of records:
data PL = Functional { name :: String, pure :: Bool }
| ObjectOriented { name :: String, multipleInheritance :: Bool }The type of pure is:
| module Main where | |
| import Prelude | |
| import Control.Monad.Eff.Console (log) | |
| import Debug.Trace (trace) | |
| f :: Int -> String | |
| f 1 = "one" | |
| f 2 = "two" | |
| f _ = "meh" |
| This is a modified version of the patch found here: | |
| https://gist.github.com/choppsv1/36aacdd696d505566088 | |
| Which itself is a modified version of: | |
| http://emacs.1067599.n5.nabble.com/RFC-Add-tty-True-Color-support-tt299962.html | |
| To use true-color, use the flag --color=true-color. | |
| Alternatively, set the EMACS_TRUE_COLOR_SEPARATOR environment variable to | |
| either ':' or ';'. |
| module Main where | |
| import Control.Applicative | |
| import Data.Monoid | |
| import Test.QuickCheck | |
| import Test.QuickCheck.Checkers | |
| import Test.QuickCheck.Classes | |
| instance Monoid a => Monoid (ZipList a) where | |
| mempty = pure mempty |
| module Main where | |
| import Control.Applicative | |
| import Data.Monoid | |
| import Test.QuickCheck | |
| import Test.QuickCheck.Checkers | |
| import Test.QuickCheck.Classes | |
| instance Monoid a => Monoid (ZipList a) where | |
| mempty = pure mempty |
| {-# LANGUAGE ExistentialQuantification #-} | |
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| module Main where | |
| -- | 'f ~> g' means natural transformation from a functor 'f' to a functor 'g' | |
| type (~>) f g = forall a. f a -> g a | |
| -- | const functor, which works as if it's just a constant |
| import Test.Hspec | |
| import Test.Hspec.QuickCheck (prop) | |
| main :: IO () | |
| main = hspec $ do | |
| describe "quickcheck" $ do | |
| prop "assoc" $ \x y z -> | |
| x + (y + z) == ((x + y) + (z :: Double)) |
Let me guess there is a data PL as a sum type of records:
data PL = Functional { name :: String, pure :: Bool }
| ObjectOriented { name :: String, multipleInheritance :: Bool }The type of pure is:
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
import Control.Applicative ((<$>), (<*>))
import Data.Maybe (isJust)import Data.Text (Text)
import Text.Blaze ((!))You can read this in my blog too.
http://noraesae.net/2016/10/14/reader-monad-and-function-composition/
Let me guess we're about to filter a list of integers, xs.
| timestampPath :: IO FilePath | |
| timestampPath = ??? | |
| -- using do, more readable. | |
| writeTimestamp :: UnixTime -> IO () | |
| writeTimestamp x = do | |
| path <- timestampPath | |
| writeFile path (encodeUnixTime x) | |
| -- using point-free style, feeling good. |