defargs-0.1: default arguments in haskell

Copyright(c) Yusuke Matsushita 2014
LicenseBSD3
MaintainerYusuke Matsushita
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Type.DefArgs

Contents

Description

Default arguments in Haskell.

Synopsis

Example

Here is a simple example.

{-# LANGUAGE NoMonomorphismRestriction #-}

import Type.DefArgs

test = defargs2 (\x y -> x ++ ", " ++ y ++ "!") "hello" "world"
test2 = defargs2 (+) (10 :: Int) 100

main = do
  putStrLn $ test Def Def
  putStrLn $ test "good morning" Def
  putStrLn $ test Def "kitty"
  putStrLn $ test "oh" "yeah"
  print $ test2 (90 :: Int) Def

This is the result.

hello, world!
good morning, world!
hello, kitty!
oh, yeah!
190

Def

data Def Source

When used as an argument, Def will be replaced with the corresponding default value by defarg, defargs2, ..., and defargs10.

Constructors

Def 

Converters

Given a function, these converters provide every argument of the function with a default value. defarg is used for a function of one argument, defargs2 is used for a function of two arguments, and so on.

The converters require concrete types for the type variables a, b, c, ...; they need concrete types in order to judge whether a type is Def or non-Def. Internally, the judgment is made by cluss.

defarg :: Good (a -> r) (a * Nil) (a' -> r) => (a -> r) -> a -> a' -> r Source

defargs2 :: Good (a -> b -> r) (a * (b * Nil)) (a' -> b' -> r) => (a -> b -> r) -> a -> b -> a' -> b' -> r Source

defargs3 :: Good (a -> b -> c -> r) (a * (b * (c * Nil))) (a' -> b' -> c' -> r) => (a -> b -> c -> r) -> a -> b -> c -> a' -> b' -> c' -> r Source

defargs4 :: Good (a -> b -> c -> d -> r) (a * (b * (c * (d * Nil)))) (a' -> b' -> c' -> d' -> r) => (a -> b -> c -> d -> r) -> a -> b -> c -> d -> a' -> b' -> c' -> d' -> r Source

defargs5 :: Good (a -> b -> c -> d -> e -> r) (a * (b * (c * (d * (e * Nil))))) (a' -> b' -> c' -> d' -> e' -> r) => (a -> b -> c -> d -> e -> r) -> a -> b -> c -> d -> e -> a' -> b' -> c' -> d' -> e' -> r Source

defargs6 :: Good (a -> b -> c -> d -> e -> f -> r) (a * (b * (c * (d * (e * (f * Nil)))))) (a' -> b' -> c' -> d' -> e' -> f' -> r) => (a -> b -> c -> d -> e -> f -> r) -> a -> b -> c -> d -> e -> f -> a' -> b' -> c' -> d' -> e' -> f' -> r Source

defargs7 :: Good (a -> b -> c -> d -> e -> f -> g -> r) (a * (b * (c * (d * (e * (f * (g * Nil))))))) (a' -> b' -> c' -> d' -> e' -> f' -> g' -> r) => (a -> b -> c -> d -> e -> f -> g -> r) -> a -> b -> c -> d -> e -> f -> g -> a' -> b' -> c' -> d' -> e' -> f' -> g' -> r Source

defargs8 :: Good (a -> b -> c -> d -> e -> f -> g -> h -> r) (a * (b * (c * (d * (e * (f * (g * (h * Nil)))))))) (a' -> b' -> c' -> d' -> e' -> f' -> g' -> h' -> r) => (a -> b -> c -> d -> e -> f -> g -> h -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> a' -> b' -> c' -> d' -> e' -> f' -> g' -> h' -> r Source

defargs9 :: Good (a -> b -> c -> d -> e -> f -> g -> h -> i -> r) (a * (b * (c * (d * (e * (f * (g * (h * (i * Nil))))))))) (a' -> b' -> c' -> d' -> e' -> f' -> g' -> h' -> i' -> r) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> a' -> b' -> c' -> d' -> e' -> f' -> g' -> h' -> i' -> r Source

defargs10 :: Good (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> r) (a * (b * (c * (d * (e * (f * (g * (h * (i * (j * Nil)))))))))) (a' -> b' -> c' -> d' -> e' -> f' -> g' -> h' -> i' -> j' -> r) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> a' -> b' -> c' -> d' -> e' -> f' -> g' -> h' -> i' -> j' -> r Source