Two new fun plugins for lambdabot
this week. The first, by Andrew Bromage, is @free, a free
theorems generator. Given a function's type, the plugin returns
theorems that hold for that function:
lambdabot> free sortBy :: (a -> a -> Ordering) -> [a] -> [a]
g x y = h (f x) (f y) => map f . sortBy g = sortBy h . map f
lambdabot> free foldl :: (a -> b -> a) -> a -> [b] -> a
f . h x = k (f x) . g => f . foldl h y = foldl k (f y) . map g
lambdabot> free filter :: (a -> Bool) -> [a] -> [a]
g x = h (f x) => map f . filter g = filter h . map f
lambdabot> free fmap :: (a -> b) -> F a -> F b
g . h = k . f => $map_F g . fmap h = fmap k . $map_F f
lambdabot> free sequence_ :: [M a] -> M ()
g y = y => mapM g (sequence_ x) = sequence_ (map (mapM f) x)
lambdabot> free unfoldr :: (b -> Maybe (a, b)) -> b -> [a]
(((
g (fst y) = fst z && f (snd y) = snd z
) =>
p y = z
) =>
mapMaybe p (h x) = k (f x)
) =>
map g . unfoldr h = unfoldr k . f
Cool, huh? Free properties for your code! (Lots of properties checkable with QuickCheck perhaps..)
The second new plugin, written by Spencer Janssen, is @undo, a desugarer
for do-notation, meaning we can plug monadic syntax into other lambdabot
plugins:
lambdabot> undo do x <- f ; y <- g ; return (mapM_ k $ x ++ y)
f >>= \ x -> g >>= \ y -> return (mapM_ k $ x ++ y)
which we can then feed to the pointfree plugin:
lambdabot> compose pl undo do x <- f ; y <- g ; return (mapM_ k $ x ++ y)
(`fmap` g) . (mapM_ k .) . (++) =<< f
or find the type of:
lambdabot> compose type compose pl undo \f g k -> do x <- f ; y <- g ; return (mapM_ k $ x ++ y)
forall a (m :: * -> *) b (m1 :: * -> *).
(Monad m, Monad m1) =>
m1 [a] -> m1 [a] -> (a -> m b) -> m1 (m ())
Haskell is fun!
/home ::
/haskell ::
permalink ::
rss
Roman Leshchinskiy mentioned yesterday that he
managed to
get GHC running SMP
Data Parallel Haskell
on a 32 cpu Sun E6900, with memory, 80G real and 500G swap (a bargain at
somewhere around $250,000 US for this midrange server)
Its fun watching GHC Haskell scale so well..
An aside: DPH uses stream fusion to automatically fuse concurrent array code.
In Data.ByteString we
adapted the rewrite rules and code, to instead fuse code over flat,
unboxed Word8 arrays, for fast strings.
/home ::
/haskell ::
permalink ::
rss
2006-08-07